delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2005/10/22/09:33:27

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
To: cygwin AT cygwin DOT com
From: Todd Rearick <trearick_news AT cox DOT net>
Subject: Re: Socket read problem on Windows XP Pro & Cygwin
Date: Sat, 22 Oct 2005 13:31:10 +0000 (UTC)
Lines: 65
Message-ID: <loom.20051022T150029-293@post.gmane.org>
References: <20051022035348.RADA2767.eastrmmtao03.cox.net@[172.18.52.8]> <4359C50C DOT 76649CA1 AT dessent DOT net> <loom DOT 20051022T083200-857 AT post DOT gmane DOT org> <20051022090719 DOT GB27476 AT calimero DOT vinschen DOT de>
Mime-Version: 1.0
User-Agent: Loom/3.14 (http://gmane.org/)
X-IsSubscribed: yes

Corinna Vinschen <corinna-cygwin <at> cygwin.com> writes:

> 
> On Oct 22 07:06, Todd Rearick wrote:
> >     while(1)
> > 	{
> > 	char buf[80];
> > 	int len;
> > 
> > 		len = recv(infd,buf,1,0);
> > 
> > 		if (len < 1)
> > 		{
> > 			printf("len = %d\n",len);
> >             printf("errno = %d\n",errno);
> >             printf("This means %s\n", strerror(errno));
> >             sleep(1);
> 
> What you're entirely missing at this point is the fact that a return
> value of 0 (zero) indicates EOF.  You don't test for this.  Instead
> you're also testing errno in case of EOF, which has no meaning in this
> case.
> 
> Corinna
> 

hmm...good point (and you are correct)....Here is the full program output 
(well...up until I hit Ctrl-C)

Connecting to localhost:8080
Redirecting output to COM4
len = 0
errno = 119
This means Operation now in progress
len = 0
errno = 119
This means Operation now in progress
len = 0
errno = 119
This means Operation now in progress
....etc....

The only reason I ever checked errno was because I was trying to get more 
information as to why it wasn't receiving the data....You're right 
though...the errno=119 must be from something earlier in the program...and 
maybe that is a clue....but (as you can see from the code) I check the returns 
of all previous calls and none fail when I run the code.

After further testing...it looks like the "connect" call sets errno...even 
though it's return value indicated no error occured....The other end of the 
socket also "thinks" it is connected.

My *NEW* question is this then:  Why do I get len = 0 over and over.  I never 
receive a character (even when I know one was transmitted).  The read first 
blocks (as it should)...until the first character is sent...and then it starts 
bailing out immediately with len=0 over and over...and I never do receive the 
character I sent in the other end of the pipe.

Thanks again for all your help,
Todd







--
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