delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2004/09/23/05:19:34

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
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: Thu, 23 Sep 2004 11:20:19 +0200
From: Corinna Vinschen <corinna-cygwin AT cygwin DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: Blocking accept() broken?
Message-ID: <20040923092019.GC12802@cygbert.vinschen.de>
Reply-To: cygwin AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
References: <2da66eca04092222055f9bdc75 AT mail DOT gmail DOT com> <20040923051622 DOT GH9804 AT trixie DOT casa DOT cgf DOT cx> <2da66eca04092222313d8a662b AT mail DOT gmail DOT com>
Mime-Version: 1.0
In-Reply-To: <2da66eca04092222313d8a662b@mail.gmail.com>
User-Agent: Mutt/1.4.2i

That's a bug in your code. You're giving an uninitialized pointer and
an uninitialized length to accept.  

Try this:

On Sep 23 15:31, Mailing List wrote:

#include <errno.h>

[...]

#ifdef THAT_WOULD_BE_BETTER
	clilen = sizeof (struct sockaddr_in);
	cliaddr = alloca (clilen);
#endif

> 	/* Infinite loop waiting for connections */
> 	for(;;)
> 	{
> 		connfd = accept(listenfd, (struct sockaddr *) cliaddr, &clilen);

		if (connfd < 0)
		  printf ("Errno: %d <%s>\n", errno, strerror(errno));
> 		
> 			
> 		/* Here would be a pthread_create to handle the incomming connection */
> 
> 	}
> 
> 	return 0;
> }


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          mailto: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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019