Mail Archives: cygwin/2000/12/09/13:47:46
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 -