(net-close) keeps socket

Q&A's, tips, howto's
Locked
pjot
Posts: 733
Joined: Thu Feb 26, 2004 10:19 pm
Location: The Hague, The Netherlands
Contact:

(net-close) keeps socket

Post 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

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post 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.

Locked