Internet connection using sockets.
SOCKET socket.server |
( |
NUMBER |
port | ) |
|
Creates a server socket, this permits, be a net server.
- Parameters
-
port | Port to use for the connection, if omitted will use port 80 by default. |
- Note
- This socket can only be used with the function socket.accept().
- Returns
- Socket object type, ready to use.
SOCKET socket.accept |
( |
SOCKET |
zock | ) |
|
It accepts a request from a client and create a direct connection socket.
- Parameters
-
zock | A socket of type server. |
- Returns
- Socket object type, ready to use.
SOCKET socket.connect |
( |
STRING |
url, |
|
|
NUMBER |
port |
|
) |
| |
Opens a socket using the adress and ports indicated.
- Parameters
-
url | Server adress. |
port | Port to use for connect. |
- Returns
- Socket object type, ready to use.
NUMBER socket.send |
( |
SOCKET |
zock, |
|
|
STRING |
data |
|
) |
| |
Send data through the socket.
- Parameters
-
zock | An opened socket. |
data | Data to send. |
- Returns
- Number of sent bytes.
NUMBER socket.send |
( |
SOCKET |
zock, |
|
|
STRING |
data, |
|
|
NUMBER |
size |
|
) |
| |
Send data through the socket.
- Parameters
-
zock | An opened socket. |
data | Data to send. |
size | Size of the data to send. |
- Returns
- Number of sent bytes.
STRING socket.recv |
( |
SOCKET |
zock, |
|
|
NUMBER |
size |
|
) |
| |
Receive data through the socket.
- Parameters
-
zock | An opened socket. |
size | Size of the data for receive. It will receive 1024 bytes default if is omitted. |
- Returns
- Data received. Also, returns the number of bytes received (may not match the number of bytes requested).
NIL socket.close |
( |
SOCKET |
zock | ) |
|
Close the socket.
- Parameters
-
- Returns
- Nothing.