"recv" returning zero bytes

I occasionally get zero bytes from a “recv” call on a TCP socket.
The socket isn’t closed; I can read it again and get more data.
“flags” are set to zero. I’m not making any ioctl calls to set the
socket nonblocking. I’m not using a timer to force the
call to abort. Is this supposed to happen?

John Nagle
Team Overbot

Hello:

One possibility is that you are reading too fast for the socket. As an
experiment, you could try inserting a delay.

Regards,

Dean

“John Nagle” <nagle@downside.com> wrote in message
news:bsralf$spk$2@inn.qnx.com

I occasionally get zero bytes from a “recv” call on a TCP socket.
The socket isn’t closed; I can read it again and get more data.
“flags” are set to zero. I’m not making any ioctl calls to set the
socket nonblocking. I’m not using a timer to force the
call to abort. Is this supposed to happen?

John Nagle
Team Overbot

John Nagle wrote:

I occasionally get zero bytes from a “recv” call on a TCP socket.
The socket isn’t closed; I can read it again and get more data.
“flags” are set to zero. I’m not making any ioctl calls to set the
socket nonblocking. I’m not using a timer to force the
call to abort. Is this supposed to happen?

I don’t think that is supposed to happen. Do you have a code fragment
that can reproduce the problem ?

Rennie

A return of zero isn’t unexpected if the other end has
sent their FIN segment. The non zero after zero doesn’t
sound right though. What’s the state of the socket as
reported by ‘netstat’? Do you have a test case?

-seanb

John Nagle <nagle@downside.com> wrote:

I occasionally get zero bytes from a “recv” call on a TCP socket.
The socket isn’t closed; I can read it again and get more data.
“flags” are set to zero. I’m not making any ioctl calls to set the
socket nonblocking. I’m not using a timer to force the
call to abort. Is this supposed to happen?

John Nagle
Team Overbot

The other end of the connection is a Sealevel Systems 1403
serial to Ethernet converter. I can generate the problem
with that hardware, but don’t have time to develop a test
case that doesn’t require it.

John Nagle
Team Overbot


Sean Boudreau wrote:

A return of zero isn’t unexpected if the other end has
sent their FIN segment. The non zero after zero doesn’t
sound right though. What’s the state of the socket as
reported by ‘netstat’? Do you have a test case?

-seanb

John Nagle <> nagle@downside.com> > wrote:

I occasionally get zero bytes from a “recv” call on a TCP socket.
The socket isn’t closed; I can read it again and get more data.
“flags” are set to zero. I’m not making any ioctl calls to set the
socket nonblocking. I’m not using a timer to force the
call to abort. Is this supposed to happen?


John Nagle
Team Overbot