(net-close) keeps socket

Started by pjot, April 07, 2008, 06:22:49 AM

Previous topic - Next topic

pjot

Hi,



After a TCP connection has been closed, the socket still has a handle. Example with DAYTIME protocol:

newLISP v.9.3.0 on Linux, execute 'newlisp -h' for more info.

> (set 'socket (net-connect "10.227.180.20" 13))
3
> (net-receive socket 'buf 1024)
27
> buf
"07 APR 2008 15:19:12 CESTrn"
> socket
3
> (net-close socket)
true
> socket
3


After a successfull (net-close), should the socket not contain a 'nil'?



Peter

Lutz

#1
No, 'net-close' should not change the contents of a symbol, only close the socket with that number. The variable holding the socket number is just a variable, not the socket, it should not be changed by the close operation.



To check if a number is a valid socket number use (net-sessions) to return a list of open sockets.