This object allows you to create a TCP server, allowing you to listen to incoming connections.
Constructor function.
var myObject = new TcpServer(events);
var myObject = new TcpServer();
var myObject = new TcpServer({ onNewConnection: function() { Console.print("New client!"); } });
Start listening for clients.
myObject.listen(address, port);
myObject.listen(address);
myObject.listen();
Freezes the execution until a new connection arrives or waitTime time elapsed.
myObject.waitForNewConnection(waitTime);
myObject.waitForNewConnection();
Returns the next pending connection as a Tcp object that can be used to read and write to the client. You should store this object if you want to write to this client later.
myObject.nextPendingConnection();
Returns the ip address on which this server is listening.
myObject.address();
Returns the port used by this server.
myObject.port();
Called when a new client has connected.
myObject.onNewConnection = function() {};
myObject.onNewConnection = function() { var client = myObject.nextPendingConnection(); // do something with the client... };