-
Notifications
You must be signed in to change notification settings - Fork 637
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
receive() returns nil, "closed" on peer's shutdown('send') #225
Comments
Also, documentation is pretty wordy and hard to grasp, because it lacks formality and example blocks. If I'll spend few time on the html-example of one function improvement, would you like to accept a PR with all functions then described like that? Original texts will remain intact of course. |
I'm facing a similar issue the 'closed' error is emitted after large amount of data received. Anyone faced/ solved the same problem? |
That is the same problem I mentioned in |
I've encountered unusual behavior in streaming sockets (both tcp and unix) in 3.0-rc1. If
client:receive('*a')
encounters EOF right after:accept()
, i.e. no data is sent by peer and it calls:shutdown('send')
on its side, then this fact is interpreted as error. While it is unusual for client to not send anything, zero read count is usually not considered an error in byte streams.As it seems from sources, C-side
socket_recv(...)
routines intentionally do this, so it's not a bug. Why it is implemented this way and shouldn't luasocket allow empty transmissions in both ways, returning''
instead ofnil, 'closed'
?As a workaround, I can check for
'closed'
status after:receive('*a')
, but I'm not sure if that will hide network issues from my code, as:this is actually very misleading, since connect() to a socket and succesful shutdown(SHUT_WR) is NOT a "close before transmission completed", it is not an error at all, because the transmission of EOF went fine, and only one side of duplex connection was shut, and the peer receiving EOF is able to send back any amount of data he has to.
My guess, it was needed to distinguish empty lines and EOF in
:receive('*l')
, so more likely the simplest solution is to make documentation more clear on this case. Something along the lines of:The text was updated successfully, but these errors were encountered: