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

Example: Socket.AcceptNext method

Demonstrates how to call the AcceptNext method.

Chilkat Java Downloads

Chilkat2 Java
import com.chilkatsoft.chilkat2.ChilkatException;
import com.chilkatsoft.chilkat2.Socket;

public class ChilkatExample {

    public static void main(String[] args) {
        Socket listenSocket = new Socket();
        Socket connectedSocket = new Socket();

        int port = 5555;
        int backlog = 25;
        try {
            listenSocket.bindAndListen(port, backlog);
        } catch (ChilkatException e) {
            System.out.println(e.getLastErrorText());
            return;
        }

        // Accept next incoming connection
        int maxWaitMs = 200000;
        try {
            listenSocket.acceptNext(maxWaitMs, connectedSocket);
        } catch (ChilkatException e) {
            System.out.println(e.getLastErrorText());
            return;
        }

        // ...
        // ...

        maxWaitMs = 20000;
        connectedSocket.closeConnection(maxWaitMs);
    }
}