Clients -
socket :
Client
Represents socket client and related remote functions.
Constructor
__init
(ClientConfig? clientConfig)
- clientConfig ClientConfig?
Remote Methods
write | Writes given data to the client socket. |
read | Reads data from the client socket. If the data has the specified length, then wait until that number of bytes are received from the client. Else, return the data available in the OS buffer. In the case of the connection being closed by the client, then return either -1 or the data that is currently available in the buffer. Number of bytes returned will be < 0 if the client closes the connection. |
close | Closes the client socket connection. |
shutdownRead | Shutdowns the further read from socket. |
shutdownWrite | Shutdowns the further write from socket. |
Fields
- remotePort int 0
-
the remote port number to which this socket is connected
- localPort int 0
-
the local port number to which this socket is bound
- remoteAddress string ()
-
the remote IP address string in textual presentation to which the socket is connected
- localAddress string ()
-
the local IP address string in textual presentation to which the socket is bound
- id int 0
-
a unique identifier to identify each client
Writes given data to the client socket.
Parameters
- content byte
-
- the content that wish to send to the client socket
-
Return Type
(int | Error) - number of bytes got written or an error if encounters an error while writing
Reads data from the client socket. If the data has the specified length, then wait until that number of bytes are received from the client. Else, return the data available in the OS buffer. In the case of the connection being closed by the client, then return either -1 or the data that is currently available in the buffer. Number of bytes returned will be < 0 if the client closes the connection.
Parameters
- length int (default -100)
-
- Positive integer. Represents the number of bytes which should be read
-
Return Type
([byte, int] | ReadTimedOutError) - Content as a byte array and the number of bytes read or an error if encounters an error while reading
Closes the client socket connection.
-
Return Type
(Error?) - an error if encounters an error while closing the connection or returns nil otherwise
Shutdowns the further read from socket.
-
Return Type
(Error?) an error if encounters an error while shutdown the read from socket or returns nil otherwise