SocketManager
Summary
SocketManager global table.
Functions
| Method | Returns |
|---|---|
| Create(port: integer) | WinSocket |
| CreateConnect(uri: string, port: integer) | WinSocket |
Functions
Create
SocketManager.Create(port: integer): WinSocketCreates 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
| Name | Type | Description |
|---|---|---|
| port | integer | The local port number to bind and listen on. |
Returns
| Type | Description |
|---|---|
| WinSocket | socket The created listening socket. |
CreateConnect
SocketManager.CreateConnect(uri: string, port: integer): WinSocketCreates 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
| Name | Type | Description |
|---|---|---|
| uri | string | The target IP address. Must be "127.0.0.1". |
| port | integer | The target port number to connect to. |
Returns
| Type | Description |
|---|---|
| WinSocket | socket The created and connected socket. |