Provides network support
DTLSSocket
DTLS/UDP secure socket
Operations
- New
- Close
- Flush
- GetAddress
- GetIssuer
- GetLastError
- GetPort
- GetSubject
- IsOpen
- ReadBuffer
- ReadByte
- ReadLine
- Select
- WriteBuffer
- WriteByte
- WriteString
Flush #
Flushes the output buffer. This is a no-opt given this socket is not backed by an output buffer.
method : public : Flush() ~ NilGetAddress #
Returns the connected network address
method : public : GetAddress() ~ StringReturn
| Type | Description |
|---|---|
| String | return network address |
GetIssuer #
Gets the X.509 certificate issuer name
method : public : GetIssuer() ~ StringReturn
| Type | Description |
|---|---|
| String | certificate issuer name |
GetLastError # function
Gets the calling thread's last DTLS failure, from a connect, listen, accept, read or write; each of those replaces it, and one that works leaves none. A connect that failed says why the system refused it, and a certificate that failed verification is described with each reason mbedTLS gives.
function : GetLastError() ~ StringReturn
| Type | Description |
|---|---|
| String | last error message, or Nil if there was none |
GetPort #
Returns the connected network port
method : public : GetPort() ~ IntReturn
| Type | Description |
|---|---|
| Int | return network port |
GetSubject #
Gets the X.509 certificate subject name
method : public : GetSubject() ~ StringReturn
| Type | Description |
|---|---|
| String | certificate subject name |
IsOpen #
Returns rather the socket is open
method : public : IsOpen() ~ BoolReturn
| Type | Description |
|---|---|
| Bool | true if socket is open, false otherwise |
New # constructor
Connects and completes a DTLS handshake. The server's certificate is verified as TCPSecureSocket verifies it, whatever verify says: its chain must lead to a trusted certificate and it must name the address connected to, or the connection is refused (IsOpen() is false; GetLastError() says why). To trust a self-signed server, pass its certificate as pem. verify does not turn verification off: false (the default) leaves it to the process -- on, unless OBJECK_TLS_INSECURE_SKIP_VERIFY=1 is set for testing -- and true requires it even then.
New(address:System.String, port:Int, pem:String, verify:Bool)Parameters
| Name | Type | Description |
|---|---|---|
| address | String | network address |
| port | Int | network port |
| pem | String | PEM file of the certificates to trust, in place of the bundled certificate authorities (optional) |
| verify | Bool | true to require verification even in insecure test mode (OBJECK_TLS_INSECURE_SKIP_VERIFY); false (the default) verifies unless that mode is on |
ReadBuffer #
Reads bytes into a byte buffer
method : public : ReadBuffer(offset:Int, num:Int, buffer:Byte[]) ~ IntParameters
| Name | Type | Description |
|---|---|---|
| offset | Int | destination buffer offset |
| num | Int | number of values to read |
| buffer | Byte | input buffer |
Return
| Type | Description |
|---|---|
| Int | number of values read |
ReadBuffer #
Reads bytes into a character buffer
method : public : ReadBuffer(offset:Int, num:Int, buffer:Char[]) ~ IntParameters
| Name | Type | Description |
|---|---|---|
| offset | Int | destination buffer offset |
| num | Int | number of values to read |
| buffer | Char | input buffer |
Return
| Type | Description |
|---|---|
| Int | number of values read |
ReadLine # native
Reads a string until a newline or character return is detected
method : public : native : ReadLine() ~ System.StringReturn
| Type | Description |
|---|---|
| String | character string |
Select #
Checks if read/write data is available
method : public : Select(is_write:Bool) ~ IntParameters
| Name | Type | Description |
|---|---|---|
| is_write | Bool | if true check for write, otherwise read |
Return
| Type | Description |
|---|---|
| Int | 1 if ready, 0 if not ready, -1 is error |
WriteBuffer #
Writes bytes from a byte buffer
method : public : WriteBuffer(buffer:Byte[]) ~ IntParameters
| Name | Type | Description |
|---|---|---|
| buffer | Byte | input buffer |
Return
| Type | Description |
|---|---|
| Int | number of values written |
WriteBuffer #
Writes bytes from a byte buffer
method : public : WriteBuffer(offset:Int, num:Int, buffer:Byte[]) ~ IntParameters
| Name | Type | Description |
|---|---|---|
| offset | Int | destination buffer offset |
| num | Int | number of values to write |
| buffer | Byte | input buffer |
Return
| Type | Description |
|---|---|
| Int | number of values written |
WriteBuffer #
Writes characters from a byte buffer
method : public : WriteBuffer(buffer:Char[]) ~ IntParameters
| Name | Type | Description |
|---|---|---|
| buffer | Char | input buffer |
Return
| Type | Description |
|---|---|
| Int | number of values written |
WriteBuffer #
Writes characters from a character buffer
method : public : WriteBuffer(offset:Int, num:Int, buffer:Char[]) ~ IntParameters
| Name | Type | Description |
|---|---|---|
| offset | Int | destination buffer offset |
| num | Int | number of values to write |
| buffer | Char | input buffer |
Return
| Type | Description |
|---|---|
| Int | number of values written |