Sample code for 30+ languages & platforms
Ruby Requires Chilkat v11.0.0+

Example: Socket.AcceptNext method

Demonstrates how to call the AcceptNext method.

Chilkat Ruby Downloads

Ruby
require 'chilkat'

success = false

listenSocket = Chilkat::CkSocket.new()
connectedSocket = Chilkat::CkSocket.new()

port = 5555
backlog = 25
success = listenSocket.BindAndListen(port,backlog)
if (success == false)
    print listenSocket.lastErrorText() + "\n";
    exit
end

#  Accept next incoming connection
maxWaitMs = 200000
success = listenSocket.AcceptNext(maxWaitMs,connectedSocket)
if (success == false)
    print listenSocket.lastErrorText() + "\n";
    exit
end

#  ...
#  ...

maxWaitMs = 20000
connectedSocket.Close()