Methods
Close()
Close closes the connection.
- Source
Throws:
- - The error encountered during connection closing.
- Type
- error
Example
let m = require('nuclei/net');
let c = m.Open('tcp', 'localhost:8080');
c.Close();Recv(N) → {Uint8Array}
Recv receives data from the connection with a timeout. If N is 0, it will read up to 4096 bytes.
Parameters:
| Name | Type | Description |
|---|---|---|
N | number | The number of bytes to receive. |
- Source
Throws:
- - The error encountered during data receiving.
- Type
- error
Returns:
- The received data in an array.
- Type:
- Uint8Array
Example
let m = require('nuclei/net');
let c = m.Open('tcp', 'localhost:8080');
let data = c.Recv(1024);RecvHex(N) → {string}
RecvHex receives data from the connection with a timeout in hex format. If N is 0, it will read up to 4096 bytes.
Parameters:
| Name | Type | Description |
|---|---|---|
N | number | The number of bytes to receive. |
- Source
Throws:
- - The error encountered during data receiving.
- Type
- error
Returns:
- The received data in hex format.
- Type:
- string
Example
let m = require('nuclei/net');
let c = m.Open('tcp', 'localhost:8080');
let data = c.RecvHex(1024);RecvString(N) → {string}
RecvString receives data from the connection with a timeout. Output is returned as a string. If N is 0, it will read up to 4096 bytes.
Parameters:
| Name | Type | Description |
|---|---|---|
N | number | The number of bytes to receive. |
- Source
Throws:
- - The error encountered during data receiving.
- Type
- error
Returns:
- The received data as a string.
- Type:
- string
Example
let m = require('nuclei/net');
let c = m.Open('tcp', 'localhost:8080');
let data = c.RecvString(1024);Send(data)
Send sends data to the connection with a timeout.
Parameters:
| Name | Type | Description |
|---|---|---|
data | Uint8Array | The data to send. |
- Source
Throws:
- - The error encountered during data sending.
- Type
- error
Example
let m = require('nuclei/net');
let c = m.Open('tcp', 'localhost:8080');
c.Send(new Uint8Array([1, 2, 3]));SendArray(data)
SendArray sends array data to connection.
Parameters:
| Name | Type | Description |
|---|---|---|
data | Uint8Array | The array data to send. |
- Source
Throws:
- - The error encountered during data sending.
- Type
- error
Example
let m = require('nuclei/net');
let c = m.Open('tcp', 'localhost:8080');
c.SendArray(new Uint8Array([1, 2, 3]));SendHex(data)
SendHex sends hex data to connection.
Parameters:
| Name | Type | Description |
|---|---|---|
data | string | The hex data to send. |
- Source
Throws:
- - The error encountered during data sending.
- Type
- error
Example
let m = require('nuclei/net');
let c = m.Open('tcp', 'localhost:8080');
c.SendHex('0x123');SetTimeout(value)
SetTimeout sets read/write timeout for the connection (in seconds).
Parameters:
| Name | Type | Description |
|---|---|---|
value | number | The timeout value in seconds. |
- Source
Example
let m = require('nuclei/net');
let c = m.Open('tcp', 'localhost:8080');
c.SetTimeout(5);