View Single Post

   
  #2 (permalink)  
Old 01-04-2008, 08:48 PM
Mcptron
 
Posts: n/a
Default Re: socket accept problem

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
>


Reply With Quote