Connect returns EINPROGRESS

kalpesh varyani at
Wed Aug 19 11:56:49 UTC 2009

Hi all,

 I am using HPUX 11.23 and looking into the socket.c code of bind-9.4.3-P3.

 Following is the code for isc_socket_connect() in the file:

isc_socket_connect(isc_socket_t *sock, isc_sockaddr_t *addr,
                  isc_task_t *task, isc_taskaction_t action, const void

        * Try to do the connect right away, as there can be only one
        * outstanding, and it might happen to complete.
       sock->address = *addr;
       cc = connect(sock->fd, &addr->, addr->length);
       if (cc < 0) {

*               /*
                * HP-UX "fails" to connect a UDP socket and sets errno to
                * EINPROGRESS if it's non-blocking.  We'd rather regard this
                * a success and let the user detect it if it's really an
                * at the time of sending a packet on the socket.
               if (sock->type == isc_sockettype_udp && errno == EINPROGRESS)
                       cc = 0;
                       goto success;

               if (SOFT_ERROR(errno) || errno == EINPROGRESS)
                       goto queue;
        * If connect completed, fire off the done event.
       if (cc == 0) {
               sock->connected = 1;
               sock->bound = 1;
               dev->result = ISC_R_SUCCESS;
               isc_task_send(task, (isc_event_t **)&dev);

               return (ISC_R_SUCCESS);

        * Poke watcher here.  We still have the socket locked, so there
        * is no race condition.  We will keep the lock for such a short
        * bit of time waking it up now or later won't matter all that much.
       if (sock->connect_ev == NULL)
               select_poke(manager, sock->fd, SELECT_POKE_CONNECT);

       sock->connect_ev = dev;

       return (ISC_R_SUCCESS);

I am noticing a strange code path here (marked in blue).My question here is,
why does the
success path being executed when errno is EINPROGRESS ?

Probably the answer is already given in the comments(/*HPUX "fails" ....*/),
but I am not able to
understand the implications. Could someone please explain why EINPROGRESS is
treated as a success
I see the query failing initially when errno is EINPROGRESS and after
retrying after 2 sec
it succeeds somehow. Could someone explain this behavior.

Thanks in advance,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the bind-users mailing list