<p>Hi all,</p>
<p> I am using HPUX 11.23 and looking into the socket.c code of bind-9.4.3-P3.</p>
<p> Following is the code for isc_socket_connect() in the file:</p>
<p><font face="courier new,monospace">isc_result_t<br>isc_socket_connect(isc_socket_t *sock, isc_sockaddr_t *addr,<br>                  isc_task_t *task, isc_taskaction_t action, const void *arg)<br>{</font></p>
<p><font face="courier new,monospace">::<br>       /*<br>        * Try to do the connect right away, as there can be only one<br>        * outstanding, and it might happen to complete.<br>        */<br>       sock->address = *addr;<br>
       cc = connect(sock->fd, &addr-><a href="http://type.sa">type.sa</a>, addr->length);  <br>       if (cc < 0) {<br>               <br></font><strong><font style="BACKGROUND-COLOR: #ffffff" face="courier new,monospace" color="#3333ff">               /*<br>
                * HP-UX "fails" to connect a UDP socket and sets errno to<br>                * EINPROGRESS if it's non-blocking.  We'd rather regard this as<br>                * a success and let the user detect it if it's really an error<br>
                * at the time of sending a packet on the socket.<br>                */<br>               if (sock->type == isc_sockettype_udp && errno == EINPROGRESS) {<br>                       cc = 0;<br>                       goto success; <br>
               }</font></strong></p>
<p><font face="courier new,monospace">               if (SOFT_ERROR(errno) || errno == EINPROGRESS)<br>                       goto queue;<br>::<br>       /*<br>        * If connect completed, fire off the done event.<br>
        */<br>success:<br>       if (cc == 0) {<br>               sock->connected = 1; <br>               sock->bound = 1;<br>               dev->result = ISC_R_SUCCESS;<br>               isc_task_send(task, (isc_event_t **)&dev);</font></p>

<p><font face="courier new,monospace">               UNLOCK(&sock->lock);<br>               return (ISC_R_SUCCESS); <br>       }</font></p>
<p><font face="courier new,monospace"> queue:<br> ....<br> ....<br>       /*<br>        * Poke watcher here.  We still have the socket locked, so there<br>        * is no race condition.  We will keep the lock for such a short<br>
        * bit of time waking it up now or later won't matter all that much.<br>        */<br>       if (sock->connect_ev == NULL)<br>               select_poke(manager, sock->fd, SELECT_POKE_CONNECT);  </font></p>

<p><font face="courier new,monospace">       sock->connect_ev = dev;</font></p>
<p><font face="courier new,monospace">       UNLOCK(&sock->lock);<br>       return (ISC_R_SUCCESS);</font></p>
<p> </p>
<p>I am noticing a strange code path here (marked in blue).My question here is, why does the <br>success path being executed when errno is EINPROGRESS ?</p>
<p>Probably the answer is already given in the comments(/*HPUX "fails" ....*/), but I am not able to<br>understand the implications. Could someone please explain why EINPROGRESS is treated as a success <br>case.</p>

<div>I see the query failing initially when errno is EINPROGRESS and after retrying after 2 sec<br>it succeeds somehow. Could someone explain this behavior.<br></div>
<div> </div>
<div>Thanks in advance,</div>
<div>Kalpesh.</div>
<div> </div>