This is the mail archive of the
cygwin@sourceware.cygnus.com
mailing list for the Cygwin project.
socketpair bug
- To: gnu-win32 at cygnus dot com
- Subject: socketpair bug
- From: newsham at lava dot net (Tim Newsham)
- Date: Wed, 6 May 1998 20:26:10 -1000 (HST)
Hi,
It looks like socketpair() doesn't properly handle growing the
file descriptor table. If you write a loop to open socketpairs, it
quits after 14 pairs. Test program included below.
I implemented my own socketpair function and I'm noticing some
strange results. It appears that connect() back to localhost occasionally
reports EADDRINUSE. To make the function more robust, I made it
try the whole operation several times (currently 3 times max). Even
with retries, it occasionally errors out. I can't imagine why winsock
would behave this way, I'm using dynamic ports for each endpoint and
not setting the reuse-address option, so there should be no chance of
getting the same port on one endpoint, let alone on both endpoints.
Very strange. Strike up another point to winsock.
Tim N.
/* this will fail after the 14th pair. I don' think cygwin is
* growing the dynamic fd table properly in this case
*/
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <errno.h>
int
main()
{
int s[2 * 100], *pair;
int i;
memset(s, 0xff, sizeof s);
for(i = 0; i < 100; i++) {
pair = &s[i * 2];
if(socketpair(AF_UNIX, SOCK_STREAM, 0, pair) == -1) {
printf("error at %d: %s\n", i, strerror(errno));
} else {
printf("%d %d\n", pair[0], pair[1]);
}
}
for(i = 0; i < 100; i++) {
pair = &s[i * 2];
close(pair[0]);
close(pair[1]);
}
return 0;
}
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".