Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Date: Sat, 17 Sep 2005 13:01:40 +0200 From: Corinna Vinschen To: cygwin AT cygwin DOT com Subject: Re: socket troubles Message-ID: <20050917110140.GS5555@calimero.vinschen.de> Reply-To: cygwin AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com References: <4a03a72c050916125687025c1 AT mail DOT gmail DOT com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4a03a72c050916125687025c1@mail.gmail.com> User-Agent: Mutt/1.4.2i 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/