SocketManager

Summary

SocketManager global table.

Functions

MethodReturns
Create(port: integer)WinSocket
CreateConnect(uri: string, port: integer)WinSocket

Functions

Create

SocketManager.Create(port: integer): WinSocket

Creates a non-blocking TCP listening socket bound to the given port on all interfaces. The socket is set to non-blocking mode and begins listening immediately. Raises an error if the socket cannot be created, bound, or set to listen.

Parameters

NameTypeDescription
portintegerThe local port number to bind and listen on.

Returns

TypeDescription
WinSocketsocket The created listening socket.

CreateConnect

SocketManager.CreateConnect(uri: string, port: integer): WinSocket

Creates a non-blocking TCP socket and connects to it. The URI must be "127.0.0.1". connections to external addresses are not allowed. Raises an error if the URI is not "127.0.0.1", or if the socket cannot be created, bound, or connected.

Parameters

NameTypeDescription
uristringThe target IP address. Must be "127.0.0.1".
portintegerThe target port number to connect to.

Returns

TypeDescription
WinSocketsocket The created and connected socket.