tcp.listenStream

Syntax tcp.listenStream (port, depth, callback, refcon, ip)

Params port is the TCP port number to listen on

depth is the maximum number of simultaneous connections to this port that Frontier will allow

callback is the address of a script that will handle the incoming connections

refcon is an optional long parameter that will be passed back verbatim to the callback script with every connection

ip is an optional parameter defaulting to 0 that determines a specific IP address to listen on.

Action Begins listening for TCP/IP connections on the specified port.

Returns A listen reference that can be closed with tcp.closeListen.

Notes tcp.listenStream returns immediately and calls the callback script asynchronously in separate threads for each incoming connection.

A listen reference is not a stream reference; you cannot use tcp.closeStream to stop a listener.

It may be more convenient to use a server framework like inetd than to call this verb directly.

The ip parameter was added in Frontier 6.2.

Discuss