delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2000/12/09/13:47:46

Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT sources DOT redhat DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT sources DOT redhat DOT com>
List-Help: <mailto:cygwin-help AT sources DOT redhat DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT sources DOT redhat DOT com
Delivered-To: mailing list cygwin AT sources DOT redhat DOT com
Date: Sat, 9 Dec 2000 13:47:25 -0500 (EST)
From: Dave Johnson <lists-cygwin AT centerclick DOT org>
To: cygwin AT cygwin DOT com
Subject: connect() returns wrong errno for non-blocking sockets
Message-ID: <Pine.LNX.4.10.10012091320090.15913-100000@alliance.centerclick.org>
MIME-Version: 1.0

While porting an application to cygwin I've discovered the following
bug:

When calling connect on a non-blocking socket it returns -1 with errno set
to EAGAIN not EINPROGRESS.  In every UNIX OS I've tried this in 
EINPROGRESS is the correct errno for non-blocking connect() calls.

This is with cygwin 1.1.4.

Is this a known problem or how it was intended to be designed?

A short example is below (note that error checking return codes is being
done, but not shown in the example):

int nonblock = 1;
int s;
struct sockaddr_in saddr;
struct hostent *remotehost;
/* to_ip is a char* with remote host */
/* to_port is a char* with remote port number */

/* create a TCP socket */
s = socket( AF_INET, SOCK_STREAM, 0);

/* setup saddr */
remotehost = gethostbyname(to_ip);
bzero ((char *) &saddr, sizeof (saddr));
saddr.sin_family = AF_INET;
saddr.sin_port = htons(atoi(to_port));
memcpy(&saddr.sin_addr,
    *((struct in_addr **)remotehost->h_addr_list),
    sizeof(struct in_addr));

/* set non-blocking so connect wont block */
ioctl(s, FIONBIO, &nonblock);

connect(s, (struct sockaddr *) &saddr, sizeof(saddr));

/* connect returns -1 and sets errno to EAGAIN */

/* then go onto a select driven loop waiting for s to become
 * writable for either success or failure
 */



--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019