Sample code for 30+ languages & platforms
Unicode C++

Example: Socket.AcceptNext method

Demonstrates how to call the AcceptNext method.

Chilkat Unicode C++ Downloads

Unicode C++
#include <CkSocketW.h>

void ChilkatSample(void)
    {
    bool success = false;

    CkSocketW listenSocket;
    CkSocketW connectedSocket;

    int port = 5555;
    int backlog = 25;
    success = listenSocket.BindAndListen(port,backlog);
    if (success == false) {
        wprintf(L"%s\n",listenSocket.lastErrorText());
        return;
    }

    //  Accept next incoming connection
    int maxWaitMs = 200000;
    success = listenSocket.AcceptNext(maxWaitMs,connectedSocket);
    if (success == false) {
        wprintf(L"%s\n",listenSocket.lastErrorText());
        return;
    }

    //  ...
    //  ...

    maxWaitMs = 20000;
    connectedSocket.Close();
    }