How to disconnect from tcp socket in NodeJs


Question

I connect to socket server in NodeJs using this command:

client = net.createConnection()

How can I then properly disconnect from the server?

I tried client.end() and even client.destroy()

but when I check the connection status using netstat it shows that the connection is in state FIN_WAIT2.

How can I close and destroy the connection altogether?

1
26
2/8/2012 3:43:36 PM

net.createConnection() returns a Socket object. client.destroy() is what you want to do.

Source: http://nodejs.org/docs/latest/api/net.html#socket.destroy

24
2/8/2012 2:51:49 PM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon