newLISP Fan Club

Forum => newLISP in the real world => Topic started by: pjot on April 07, 2008, 06:22:49 AM

Title: (net-close) keeps socket
Post by: pjot on April 07, 2008, 06:22:49 AM
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
Title:
Post by: Lutz on April 07, 2008, 08:40:47 AM
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.