Module nixio.TLSSocket
TLS Socket Object.
TLS Sockets contain the underlying socket and context in the fields "socket" and "context".
Functions
connect () | Initiate the TLS handshake as client with the server. |
accept () | Wait for a TLS handshake from a client. |
send (buffer, offset, length) | Send a message to the socket. |
write (buffer, offset, length) | Send a message on the socket (This is an alias for send). |
recv (length) | Receive a message on the socket. |
read (length) | Receive a message on the socket (This is an alias for recv). |
shutdown () | Shut down the TLS connection. |
Functions
- connect ()
-
Initiate the TLS handshake as client with the server.
Returns:
-
true
See also:
Usage:
This function calls SSL_connect().
You have to call either connect or accept before transmitting data.
- accept ()
-
Wait for a TLS handshake from a client.
Returns:
-
true
See also:
Usage:
This function calls SSL_accept().
You have to call either connect or accept before transmitting data.
- send (buffer, offset, length)
-
Send a message to the socket.
Parameters:
- buffer Buffer holding the data to be written.
- offset Offset to start reading the buffer from. (optional)
- length Length of chunk to read from the buffer. (optional)
Returns:
-
number of bytes written
Usage:
This function calls SSL_write().
<strong>Warning:</strong> It is not guaranteed that all data in the buffer is written at once. You have to check the return value - the number of bytes actually written - or use the safe IO functions in the high-level IO utility module.
Unlike standard Lua indexing the lowest offset and default is 0.
- write (buffer, offset, length)
-
Send a message on the socket (This is an alias for send).
See the send description for a detailed description.
Parameters:
- buffer Buffer holding the data to be written.
- offset Offset to start reading the buffer from. (optional)
- length Length of chunk to read from the buffer. (optional)
Returns:
-
number of bytes written
See also:
- recv (length)
-
Receive a message on the socket.
Parameters:
- length Amount of data to read (in Bytes).
Returns:
-
buffer containing data successfully read
Usage:
This function calls SSL_read().
<strong>Warning:</strong> It is not guaranteed that all requested data is read at once. You have to check the return value - the length of the buffer actually read - or use the safe IO functions in the high-level IO utility module.
The length of the return buffer is limited by the (compile time) nixio buffersize which is <em>nixio.const.buffersize</em> (8192 by default). Any read request greater than that will be safely truncated to this value.
- read (length)
-
Receive a message on the socket (This is an alias for recv).
See the recv description for more details.
Parameters:
- length Amount of data to read (in Bytes).
Returns:
-
buffer containing data successfully read
See also:
- shutdown ()
-
Shut down the TLS connection.
Returns:
-
true
Usage:
This function calls SSL_shutdown().