socket accept problem hi!
unter aix 4.3.3 and gcc 2.9 i have a problem on subsequent accept calls
on a server socket. here my sample code:
---
#include <netinet/in.h>
#include <sys/socket.h>
#define QUEUE_SIZE 2
main()
{ int s, c;
struct sockaddr_in addr;
addr.sin_family =AF_INET;
addr.sin_addr.s_addr = INADDR_ANY;
addr.sin_port = htons((u_short) 7111);
s = socket(AF_INET, SOCK_STREAM, 0);
bind(s, (struct sock_addr *) &addr, sizeof(addr));
listen(s, QUEUE_SIZE);
while (1)
{ c = accept(s, NULL, NULL);
close(c);
}
}
---
depending on the QUEUE_SIZE, accept never comes back after a defined
number of calls:
size calls
1 1
2 3
3 4
4 6
5 7
6 9
a connection try to the server port times out then but netstat -a still
shows me that port in listening mode. and my program hangs...
does someone know anything about that?
thx.
mike |