Mail Archives: cygwin/2005/09/17/07:02:04
On Sep 16 21:56, znort wrote:
> while(1)
> {
> errno=0;
>
> sock = accept(sd, NULL,NULL);
>
> if (errno==0)
> {
> rf = fork();
>
> /* father will still listener forever */
> if (!rf)
> {
> fcntl(sock, F_SETFL, f & (~O_NONBLOCK) );
>
> shutdown(sd, SHUT_RDWR);
> recv(sock, ok, 2048, 0);
>
> sprintf(ok, "01101996 123 444");
> send(sock, ok, strlen(ok)+1, 0);
>
> /* no return from client just to "block" the child */
> recv(sock, ok, 2048, 0);
>
> shutdown(sock, SHUT_RDWR);
>
> break;
> }
> }
> else
> {
> printf("errno = %d", errno);
> }
> }
You're waisting resources, that's the problem. Observe the handle
usage of your server process while running the client, and you'll
be surprised.
shutdown doesn't close the socket and consequentially doesn't remove
the socket from the system tables. Use close instead of shutdown.
Also, if you never call wait or waitpid to reap child processes, you
end up with lots of zombie processes (the child processes you don't
see in task manager).
Next time, please convert your test application to compile under gcc,
not VC++.
Corinna
--
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Project Co-Leader cygwin AT cygwin DOT com
Red Hat, Inc.
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
- Raw text -