This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Cygwin && TCP && O_NONBLOCK


"Roderick Groesbeek" <rgroesb@triple-it.nl> wrote:
> Situation:
> =======
> - 1 NON_BLOCKING tcp socket
> - First connect() gives EINPROGRESS
> - Second connect() gives:
>   * On Linux: nResult == 0
>   * On Cygwin: nResult == -1 && errno == EISCONN
>
>
> Question:
> =======
> Which behaviour is right?
> Where could I check the specifications for the implementations?

According to the (current?) Open Group spec for connect(2):

> If the connection cannot be established immediately and
> O_NONBLOCK is set for the file descriptor for the socket,
> connect() shall fail and set errno to [EINPROGRESS],
> but the connection request shall not be aborted,
> and the connection shall be established asynchronously.
> Subsequent calls to connect() for the same socket,
> before the connection is established, shall fail
> and set errno to [EALREADY].
>
> When the connection has been established asynchronously,
> select() and poll() shall indicate that the file descriptor
> for the socket is ready for writing.

So I assume you call connect(2) once then wait for select(2) or poll(2) to
give you a writable status, which they do once the connection eventually
succeeds or fails (this is mentioned in their respective man pages). So it
looks like Linux is wrong and cygwin is right.

// Conrad




--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]