Recv() is not blocking?

Hi All!

I’m writing a TCP server application and am having trouble with sockets, specifically with recv().

recv() is supposed to block as long as you don’t set SO_NONBLOCK, but this doesn’t seem to be the case. recv() does NOT block…ever.

Same code works fine on Windows using raw sockets. I tried looking at the sources and demo apps, but they are doing nothing different and in fact actually do their own blocking by not calling recv() unless they are expecting data, so not much help there.

Am I just missing something? Does Haiku require the use of select() for blocking?

Thanks!!

recv is also not blocking if you set MSG_NOWAIT. But it might return immediately for many reasons. Did you check the returned error code? If it’s not EWOULDBLOCK or ETIMEDOUT, then the reason it’s returning immediately isn’t due to the socket being non-blocking.

I don’t use MSG_NOWAIT and yes, I checked the error code and it is always EWOULDBLOCK. It’s like the socket is set as non blocking, but I haven’t set it as such.

Thanks.

Ugh! So I reboot the machine without making any changes and now it works perfectly. What the…?