recv returns 0; errno = EAGAIN
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix Programming > recv returns 0; errno = EAGAIN




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    recv returns 0; errno = EAGAIN  
Raja


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
02-18-04 01:33 AM

I have a recv call to a socket and the return value from recv is 0 and
the errno is EAGAIN. There are lots of discussions around this but i
couldnt get a clear picture anywhere.
What are the chances of recv returning 0 and EAGAIN? The manual says
only if recv is -1, you should check for EAGAIN. Should i ignore the
value of errno if recv returns a 0?

Thanks
Raja





[ Post a follow-up to this message ]



    Re: recv returns 0; errno = EAGAIN  
Ian Fitchet


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
02-18-04 01:33 AM

raja0576@yahoo.com (Raja) writes:

> couldnt get a clear picture anywhere.

The clear picture is, for all system calls, errno has no useful value
unless the system call has failed.

recv() didn't fail, it told you there were no bytes received.  Why
recv() reported no bytes returned is a different problem which you
may wish to ask again regarding.


Man pages are notoriously terse but on the whole they tell you the
facts.

Cheers,

Ian





[ Post a follow-up to this message ]



    Re: recv returns 0; errno = EAGAIN  
Andrei Voropaev


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
02-18-04 04:33 AM

On 2004-02-18, Raja <raja0576@yahoo.com> wrote:
> I have a recv call to a socket and the return value from recv is 0 and
> the errno is EAGAIN. There are lots of discussions around this but i
> couldnt get a clear picture anywhere.
> What are the chances of recv returning 0 and EAGAIN? The manual says
> only if recv is -1, you should check for EAGAIN. Should i ignore the
> value of errno if recv returns a 0?

Check if errno was set before call to recv?
Generally, check errno only if return value is -1. No -1  - no error.

Andrei





[ Post a follow-up to this message ]



    Re: recv returns 0; errno = EAGAIN  
Nils O. newsgroup user


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
02-18-04 06:34 AM

In article <1a26ae5d.0402180127.3e89a257@posting.google.com>, Raja wrote:
> I have a recv call to a socket and the return value from recv is 0 and
> the errno is EAGAIN. There are lots of discussions around this but i
> couldnt get a clear picture anywhere.
> What are the chances of recv returning 0 and EAGAIN? The manual says
> only if recv is -1, you should check for EAGAIN. Should i ignore the
> value of errno if recv returns a 0?
If a call didn't fail, which in this case it did not since
it didn't return -1 ,you shouldn't check errno nor trust its value.

--
Vennlig hilsen/Best Regards
Nils Olav Selåsdal
System Engineer
w w w . u t e l s y s t e m s . c o m





[ Post a follow-up to this message ]



    Re: recv returns 0; errno = EAGAIN  
Fletcher Glenn


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
02-18-04 09:34 AM



Raja wrote:
> I have a recv call to a socket and the return value from recv is 0 and
> the errno is EAGAIN. There are lots of discussions around this but i
> couldnt get a clear picture anywhere.
> What are the chances of recv returning 0 and EAGAIN? The manual says
> only if recv is -1, you should check for EAGAIN. Should i ignore the
> value of errno if recv returns a 0?
>
> Thanks
> Raja

EAGAIN is not the issue here.  When recv return zero, it means EOF for
the socket connection.

--

Fletcher Glenn






[ Post a follow-up to this message ]



    Re: recv returns 0; errno = EAGAIN  
Barry Margolin


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
02-18-04 02:34 PM

In article <40339D34.4040702@removethisfoglight.com>,
Fletcher Glenn <fletcher@removethisfoglight.com> wrote:

> Raja wrote: 
>
> EAGAIN is not the issue here.  When recv return zero, it means EOF for
> the socket connection.

Assuming it's a stream socket.  If it's a datagram socket, it means you
received an empty messsage.

--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***





[ Post a follow-up to this message ]



    Re: recv returns 0; errno = EAGAIN  
Fletcher Glenn


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
02-18-04 04:34 PM



Barry Margolin wrote:
> In article <40339D34.4040702@removethisfoglight.com>,
>  Fletcher Glenn <fletcher@removethisfoglight.com> wrote:
>
> 
>
>
> Assuming it's a stream socket.  If it's a datagram socket, it means you
> received an empty messsage.
>

This is a direct quote from the man page for recv():

recv() may be used only on a con-
nected socket (see connect(3SOCKET))

--

Fletcher Glenn






[ Post a follow-up to this message ]



    Re: recv returns 0; errno = EAGAIN  
David Schwartz


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
02-18-04 05:34 PM


"Fletcher Glenn" <fletcher@removethisfoglight.com> wrote in message
news:403408C2.703@removethisfoglight.com...

 


> This is a direct quote from the man page for recv():
>
>  recv() may be used only on a con-
>      nected socket (see connect(3SOCKET))


What's your point? UDP *sockets* can be connected.

DS








[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 03:00 PM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register