Sample code for 30+ languages & platforms
C++

Example: Socket.AcceptNext method

Demonstrates how to call the AcceptNext method.

Chilkat C++ Downloads

C++
#include <CkSocket.h>

void ChilkatSample(void)
    {
    bool success = false;

    CkSocket listenSocket;
    CkSocket connectedSocket;

    int port = 5555;
    int backlog = 25;
    success = listenSocket.BindAndListen(port,backlog);
    if (success == false) {
        std::cout << listenSocket.lastErrorText() << "\r\n";
        return;
    }

    //  Accept next incoming connection
    int maxWaitMs = 200000;
    success = listenSocket.AcceptNext(maxWaitMs,connectedSocket);
    if (success == false) {
        std::cout << listenSocket.lastErrorText() << "\r\n";
        return;
    }

    //  ...
    //  ...

    maxWaitMs = 20000;
    connectedSocket.Close();
    }