Question: Using the recv() function in C to read from a 'stream' socket, can the len parameter be zero?

The recv() function returns zero for 'remote connection closed' and the number of bytes actually read on normal operation, so it sounds problematic if it should read zero bytes.

P.S.  

Yes I know to deal with it separately, and not get to this situation, still I'm wondering if the function can handle it, I can't find any documentation about it.

Answer: 
I believe the answer is "it depends". **If it is not specified by the standard** (and indeed I believe it isn't) any implementation could do as it pleases.

* It could fail with `EINVAL`
* It could hang
* It could return `0` and go on
* It could print a funny message and start the game rogue (I understand `gcc` used to do that :)) )

Actually on my implementation, it returns 0 and goes on. To check if it failed or simply returned 0, you can check `errno` after the call, so it's not as problematic as you may think.
I don't think the length parameter can be zero since even an empty string (message) needs to be terminated with '\0'.