Page 1 of 1

(net-close) keeps socket

Posted: Mon Apr 07, 2008 1:22 pm
by pjot
Hi,

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

Code: Select all

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 CEST\r\n"
> socket
3
> (net-close socket)
true
> socket
3
After a successfull (net-close), should the socket not contain a 'nil'?

Peter

Posted: Mon Apr 07, 2008 3:40 pm
by Lutz
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.