net.accept()
Accepts a TCP peer.
Signature
net.accept(listener[, timeout])
Parameters
Open TCP listener and optional nonnegative duration or null, default listener's timeout.
Returns
Connected socket owned by the same VM.
Behavior
Blocks until a connection is ready and handles TLS if configured. Close the accepted socket independently.
Errors
Wrong socket type, timeout, accept failure or handshake error.
Example
use net
listener = net.listen('127.0.0.1', 0, {timeout = 2})
client = net.connect('127.0.0.1', net.local(listener).port, {timeout = 2})
peer = net.accept(listener, 2)
net.close(peer)
net.close(client)
net.close(listener)