Object Instance nixio.TLSSocket

TLS Socket Object. TLS Sockets contain the underlying socket and context in the fields "socket" and "context".

Functions

TLSSocket:accept () Wait for a TLS handshake from a client.
TLSSocket:connect () Initiate the TLS handshake as client with the server.
TLSSocket:read  (length) Receive a message on the socket (This is an alias for recv).
TLSSocket:recv (length) Receive a message on the socket.
TLSSocket:send (buffer, offset, length) Send a message to the socket.
TLSSocket:shutdown () Shut down the TLS connection.
TLSSocket:write (buffer, offset, length) Send a message on the socket (This is an alias for send).


Functions

TLSSocket:accept ()
Wait for a TLS handshake from a client.

Usage

  • This function calls SSL_accept().
  • You have to call either connect or accept before transmitting data.

Return value:

true

See also:

TLSSocket:connect ()
Initiate the TLS handshake as client with the server.

Usage

  • This function calls SSL_connect().
  • You have to call either connect or accept before transmitting data.

Return value:

true

See also:

TLSSocket: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).

Return value:

buffer containing data successfully read

See also:

TLSSocket:recv (length)
Receive a message on the socket.

Parameters

  • length: Amount of data to read (in Bytes).

Usage

  • This function calls SSL_read().
  • Warning: 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 nixio.const.buffersize (8192 by default). Any read request greater than that will be safely truncated to this value.

Return value:

buffer containing data successfully read
TLSSocket: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)

Usage

  • This function calls SSL_write().
  • Warning: 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.

Return value:

number of bytes written
TLSSocket:shutdown ()
Shut down the TLS connection.

Usage:

This function calls SSL_shutdown().

Return value:

true
TLSSocket: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)

Return value:

number of bytes written

See also:

Valid XHTML 1.0!