tcp
Network TCP blocking sockets
Functions
1. tcp::accept
Accepts incoming connection on listening socket.
Type definition
func(socket: int, timeout: int -> int)
List of arguments
Name | Type | Description |
---|---|---|
socket | int | Listening socket handle |
timeout | int | Time waiting for incoming connection |
List of results
Name | Type | Description |
---|---|---|
- | int | Handle of socket with connected client or 0 |
2. tcp::close
Disconnects and closes a socket.
Type definition
func(socket: int)
List of arguments
Name | Type | Description |
---|---|---|
socket | int | Socket handle |
List of results
This function returns no results
3. tcp::connect
Connects to remote IP abd port.
Type definition
func(ip: string, port: int -> int)
List of arguments
Name | Type | Description |
---|---|---|
ip | string | Remote IP |
port | int | Remote port |
List of results
Name | Type | Description |
---|---|---|
- | int | Handle of a socket |
4. tcp::listen
Opens a listening socket on given port and interface.
Type definition
func(ip: string, port: int -> int)
List of arguments
Name | Type | Description |
---|---|---|
ip | string | Interface to listen to |
port | int | Listening port |
List of results
Name | Type | Description |
---|---|---|
- | int | Handle of a socket |
5. tcp::receive
Receives a stream from a socket adn saves it ot file.
Type definition
func(socket: int, file: int, timeout: int)
List of arguments
Name | Type | Description |
---|---|---|
socket | int | Socket handle |
file | int | File handle |
timeout | int | Read timeout |
List of results
This function returns no results
6. tcp::remote
Returns remote IP and port from a socket.
Type definition
func(socket: int -> struct(ip: string, port: int))
List of arguments
Name | Type | Description |
---|---|---|
socket | int | Socket handle |
List of results
Name | Type | Description |
---|---|---|
ip | string | Remote IP |
port | int | Remote port |
7. tcp::send
Read bytes from file and sends them to socket.
Type definition
func(socket: int, file: int)
List of arguments
Name | Type | Description |
---|---|---|
socket | int | Socket handle |
file | int | File handle |
List of results
This function returns no results