You need to have firmware 7.2.15 or higher. From the Beta Dev guide. You will need to use Port 1024 or higher as this is Linux and the socket must be non-blocking and use onConnect.
Now, on to capturing the instance of the client socket and not the server socket. I strongly suspect that Javascript 'this' evaluated during onConnect callback will be the client socket that you can later close, etc...
Lynde
A.13.5.3. tcpsocket.listen() (available since application version 7.2.15) Synopsis
tcpsocket.listen(port)
Purpose Start listening for inbound TCP connections.
Parameters port Integer Port number on which to listen.
Only port numbers 1024 or higher are supported, lower port numbers are reserved for the system.
Exceptions • Not enough arguments specified • Argument is not a positive integer number • Argument out of range • Socket is blocking • Address already in use • Socket not ready • Socket error
Additional info
The socket must be non-blocking, or an exception will be thrown. Furthermore, a given socket can only listen on a single port at once. When a new inbound TCP connection is established, the socket's onConnect callback will be invoked with a newly created TCPSocket instance as an argument. This new socket can then be used to communicate with the client