using net-close

Started by methodic, February 15, 2008, 02:12:23 AM

Previous topic - Next topic

methodic

I am working on sort of a handshaking protocol, and I iterate a while loop as long as my socket file descriptor is open and valid. Once I'm at the end of my communications, I use net-close to close the connection. At this point however my main loop still sees the socket as a valid descriptor. Would it make sense to have net-close assign the variable to nil after it's finished? Maybe I am over-looking something? This is on 9.3.0.



Thanks.

Lutz

#1
Your net-receive will return nil as soon as the other side closes the socket. The  first net-send after the other side closed the socket will still return the number of characters sent, but the next will fail with nil too.



The net-send has no way to find out before at least trying once if the receiver closed its socket.



So when your listening loop is on the net-receive side, you can just check for the nil return value, but to manage the situation for the sender side you need to implement some sort of protocol between client and server.



Normally there is one part of the conversation controlling it. That part should make the last send, signalling the end of the conversation.



Lutz