React Native Requires Chilkat v11.0.0+
React Native
Example: Socket.AcceptNext method
Demonstrates how to call the AcceptNext method.Chilkat React Native Downloads
import { Socket } from '@chilkat/react-native'
async function chilkatExample() {
const listenSocket = new Socket();
const connectedSocket = new Socket();
const port = 5555;
const backlog = 25;
try {
await listenSocket.bindAndListenAsync(port, backlog);
} catch {
console.log(listenSocket.lastErrorText);
return;
}
// Accept next incoming connection
let maxWaitMs = 200000;
try {
await listenSocket.acceptNextAsync(maxWaitMs, connectedSocket);
} catch {
console.log(listenSocket.lastErrorText);
return;
}
// ...
// ...
maxWaitMs = 20000;
await connectedSocket.closeAsync(maxWaitMs);
}