Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I am not a TCP/IP expert, but I did notice that this documentation says <code>EPIPE</code> can still be returned even when MSG_NOSIGNAL is set with a 'stream oriented socket'. It looks like you are creating your socket with <code>SOCK_STREAM</code>. The other end may be breaking the connection.</p> <p>In <code>CBSocketConnect()</code> it looks like if you get <code>EINPROGRESS</code> you just return true-- which you also return if it connects successfully. You would have no way of knowing if you needed to wait for the connection to finish. According to <a href="http://www.kernel.org/doc/man-pages/online/pages/man2/connect.2.html" rel="nofollow noreferrer">this</a> you could <code>select()</code> or <code>poll()</code> for connection completion.</p> <hr> <p>The above is a repost of my comments from the OP at the request of @MatthewMitchell and @user315052.</p> <hr> <p><strong>Edit:</strong> <a href="https://stackoverflow.com/users/315052/user315052">I</a> am adding a more detailed description of <a href="https://stackoverflow.com/a/12068942/315052">this answer</a>, and some of the discussion that followed.</p> <p>So, first try to do the <code>connect()</code>. Then, if <code>EINPROGRESS</code> is the error result, register for a write event wakeup from <code>libevent</code>. After getting into the callback function for <code>EV_WRITE</code>, check to see the status of the connection with <code>getsockopt()</code> with socket option <code>SO_ERROR</code> at level <code>SOL_SOCKET</code>. If the option value returned is <code>0</code>, the connection has succeeded. Otherwise, treat it as an <code>errno</code> number.</p> <p>After following this advice as illustrated in <a href="https://stackoverflow.com/a/12068942/315052">this answer</a>, you discovered that the client encountered the error <code>ECONNREFUSED</code>. This explains why your writes were failing with <code>EPIPE</code>. After investigating your server, you found that the server was not able to listen to the bound address because of the error <code>EADDRINUSE</code>. This can be dealt with by setting the <code>SO_REUSEADDR</code> option on the listening socket.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload