Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Message-ID: <08ce01c2134f$7e2a4a00$6132bc3e@BABEL> From: "Conrad Scott" To: References: <007f01c21348$72149600$5a6d3850 AT piggy> Subject: Re: Cygwin && TCP && O_NONBLOCK Date: Fri, 14 Jun 2002 03:59:25 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 "Roderick Groesbeek" 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/