vBulletin Search Engine Optimization
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| 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 |
| |||
| ok, and now the nice one: even the demo code from the official ibm documentation under http://publib.boulder.ibm.com/doc_li...taccept_ex.htm has the problem. i've tried it on a aix 4.1.5 machine -> no problem, same code works fine. on the other hand: i've compiled on the same 4.3.3 and gcc 2.9 apache and openssh, which are working fine both... what's going on here? rg. mike Michael Petroni wrote: > 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 > |
| ||||
| Mcptron <mcptron@gmx.net> wrote in message news:<09Urb.683644$Id.99675@news.easynews.com>... > ok, and now the nice one: > > even the demo code from the official ibm documentation under > > http://publib.boulder.ibm.com/doc_li...taccept_ex.htm > > has the problem. > > i've tried it on a aix 4.1.5 machine -> no problem, same code works fine. > > on the other hand: i've compiled on the same 4.3.3 and gcc 2.9 apache > and openssh, which are working fine both... > > what's going on here? > > rg. > mike > > > Michael Petroni wrote: > > > 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 > > Mike, Here's your code, with one small change. 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); /* original bind(s, (struct sock_addr *) &addr, sizeof(addr)); * replacement below */ bind(s, (struct sockaddr *) &addr, sizeof(addr)); listen(s, QUEUE_SIZE); while (1) { c = accept(s, NULL, NULL); close(c); } } I compiled this on AIX 4.3.3 with "C for AIX" compiler (vac ) version 5. I also compiled it on AIX 5.1 with "C for AIX" complier (vac) version 6. In both cases they ran flawlessly... ....I stopped testing at 30 successful accepts. -tony |