Professional Web Applications Themes

recv returns 0; errno = EAGAIN - UNIX Programming

com (Raja) writes:   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...

  1. #1

    Default Re: recv returns 0; errno = EAGAIN

    com (Raja) writes:
     

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

  2. #2

    Default recv returns 0; errno = EAGAIN

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

  3. #3

    Default Re: recv returns 0; errno = EAGAIN

    On 2004-02-18, Raja <com> wrote: 

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

    Andrei
    Andrei Guest

  4. #4

    Default Re: recv returns 0; errno = EAGAIN

    In article <google.com>, Raja wrote: 
    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
    Nils Guest

  5. #5

    Default Re: recv returns 0; errno = EAGAIN



    Raja wrote: 

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

    --

    Fletcher Glenn

    Fletcher Guest

  6. #6

    Default Re: recv returns 0; errno = EAGAIN

    In article <com>,
    Fletcher Glenn <com> wrote:
     
    >
    > EAGAIN is not the issue here. When recv return zero, it means EOF for
    > the socket connection.[/ref]

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

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

  7. #7

    Default Re: recv returns 0; errno = EAGAIN



    Barry Margolin wrote: 
    >>
    >>EAGAIN is not the issue here. When recv return zero, it means EOF for
    >>the socket connection.[/ref]
    >
    >
    > Assuming it's a stream socket. If it's a datagram socket, it means you
    > received an empty messsage.
    >[/ref]

    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

    Fletcher Guest

  8. #8

    Default Re: recv returns 0; errno = EAGAIN


    "Fletcher Glenn" <com> wrote in message
    news:com...

     [/ref]

     


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

    DS



    David Guest

Similar Threads

  1. recv and MSG_WAITALL
    By Barry Margolin in forum UNIX Programming
    Replies: 1
    Last Post: August 1st, 12:40 AM
  2. EAGAIN during socket read
    By turtle in forum Sun Solaris
    Replies: 3
    Last Post: July 16th, 07:33 PM
  3. no recv
    By David Schwartz in forum UNIX Programming
    Replies: 1
    Last Post: July 9th, 03:38 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139