This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Socket read problem on Windows XP Pro & Cygwin


On Oct 22 13:31, Todd Rearick wrote:
> Corinna Vinschen <corinna-cygwin <at> cygwin.com> writes:
> > 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.
> 
> 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 

No, the errno is set on some internal operation and has nothing to do
with something going wrong in your application.  Your job is to react
appropriately to a return value of 0 which just means EOF.  The error
value you receive at that point is just meaningless.

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

This I can't tell you since I don't know the server side of the
connection.  It's normal to get EOF (== 0) over and over again if EOF
has been detected.  This behaviour can be observed on, for instance,
Linux, too.

FYI, I tried your application against a simple time server, port 37,
which is known to accept a connection, sends 4 bytes and then closes the
connection.


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/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]