ssCore.TCP.listen

Listen for an incoming TCP connection on the specified port.


Availability:

First available in version 3.0 build 2039.


Input Parameters:

port - Port to listen on.

localAddress - [Optional] - Local address on which the socket will be created. Default value is 0.0.0.0.


Output Parameters:

No output parameters.


Asynchronous Mode:

When this method is called asynchronously, a return object containing the output parameters is passed to the specified callback function.

ssCore.TCP.listen( paramsObject [, callbackParamsObject] [, errorParamsObject] );


Synchronous Mode:

This method can only be called asynchronously.


Notes:

TCP.listen creates a server socket on the specified port.

It is possible to create a server socket on a specific network interface by specifying the localAddress of the interface in question. This is useful, for example, for creating bridging software between two subnets, where one socket is used to receive messages from one subnet and relays them to the other subnet.

When a client connects to the socket, an onConnect notification is sent, passing the address of the client to the event handler.

When the client disconnects, an onDisconnect event notification is sent to the event handler, and the socket is automatically put back in the listening mode, waiting for the next connection.

Though a socket can only connect to one client at a time, it is possible to set up multiple server sockets all listening on the same port. Clients will connect to the listening sockets in a random fashion; no assumptions can be made as to the sequence in which sockets will be connected.

                

Examples:

ssCore.TCP.listen({port:3045, localAddress:"192.168.123.20"});