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: Fri, 14 Feb 2003 12:37:49 +0100 From: Corinna Vinschen To: cygwin AT cygwin DOT com Subject: Re: Socket problem after fork() Message-ID: <20030214113749.GE31632@cygbert.vinschen.de> Reply-To: cygwin AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4i On Fri, Feb 14, 2003 at 10:33:23AM +0000, Henry Richard wrote: > This time I upgrade my cygwin version to 1.3.20 and using gcc 3.2. The > program I submit last time does work in this new environment. How ever, I > have found that fork() can't be executed twice before closing the socket, > otherwise the telnet client will be blocked unless giving it a ^]. > > I think this problem is also caused by Winsock2 in Windows 2000 system, > according to Microsoft KB. > [...] I did play with sockets a lot to get it working almost as on POSIX systems. Actually I have no way around the described problem so far as long as the application isn't changed. However, the change is simple and useful, just add a shutdown() call prior to the child's close(): > loop=2;/* if loop is greater than 1, socket won't be closed > */ > for (i = 0; i < loop; i++) { > pid = fork(); > if (pid > 0) { > close(accefd); > return 0; > } > } shutdown (accefd, SHUT_RDWR); > close(accefd); > sleep(100000); > } > } This helps. Corinna -- Corinna Vinschen Please, send mails regarding Cygwin to Cygwin Developer mailto:cygwin AT cygwin DOT com Red Hat, Inc. -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Bug reporting: http://cygwin.com/bugs.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/