Java Requires Chilkat v11.0.0+
Chilkat2 Java
Example: Socket.AcceptNext method
Demonstrates how to call the AcceptNext method.Chilkat Java Downloads
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);
}
}