Sample code for 30+ languages & platforms
Node.js

Example: Socket.AcceptNext method

Demonstrates how to call the AcceptNext method.

Chilkat Node.js Downloads

Node.js
NODEJS_PRELUDE

function chilkatExample() {

    var success = false;

    var listenSocket = new chilkat.Socket();
    var connectedSocket = new chilkat.Socket();

    var port = 5555;
    var backlog = 25;
    success = listenSocket.BindAndListen(port,backlog);
    if (success == false) {
        console.log(listenSocket.LastErrorText);
        return;
    }

    //  Accept next incoming connection
    var maxWaitMs = 200000;
    success = listenSocket.AcceptNext(maxWaitMs,connectedSocket);
    if (success == false) {
        console.log(listenSocket.LastErrorText);
        return;
    }

    //  ...
    //  ...

    maxWaitMs = 20000;
    connectedSocket.Close();

}

chilkatExample();