Example
NetConn
NetConn
void
Close closes the connection.
void
Example
N
): Uint8Array
Recv is similar to RecvFull but does not guarantee full read instead
it creates a buffer of N bytes and returns whatever is returned by the connection
for reading headers or initial bytes from the server this is usually used.
for reading a fixed number of already known bytes (ex: body based on content-length) use RecvFull.
Name | Type |
---|---|
N | number |
Uint8Array
Example
N
): Uint8Array
RecvFull receives data from the connection with a timeout.
If N is 0, it will read all data sent by the server with 8MB limit.
it tries to read until N bytes or timeout is reached.
Name | Type |
---|---|
N | number |
Uint8Array
Example
N
): string
RecvFullHex receives data from the connection with a timeout
in hex format.
If N is 0,it will read all data sent by the server with 8MB limit.
until N bytes or timeout is reached.
Name | Type |
---|---|
N | number |
string
Example
N
): string
RecvFullString receives data from the connection with a timeout
output is returned as a string.
If N is 0, it will read all data sent by the server with 8MB limit.
Name | Type |
---|---|
N | number |
string
Example
N
): string
RecvHex is similar to RecvFullHex but does not guarantee full read instead
it creates a buffer of N bytes and returns whatever is returned by the connection
for reading headers or initial bytes from the server this is usually used.
for reading a fixed number of already known bytes (ex: body based on content-length) use RecvFull.
Name | Type |
---|---|
N | number |
string
Example
N
): string
RecvString is similar to RecvFullString but does not guarantee full read, instead
it creates a buffer of N bytes and returns whatever is returned by the connection
for reading headers or initial bytes from the server this is usually used.
for reading a fixed number of already known bytes (ex: body based on content-length) use RecvFullString.
Name | Type |
---|---|
N | number |
string
Example
data
): void
Send sends data to the connection with a timeout.
Name | Type |
---|---|
data | string |
void
Example
data
): void
SendArray sends array data to connection
Name | Type |
---|---|
data | any |
void
Example
data
): void
SendHex sends hex data to connection
Name | Type |
---|---|
data | string |
void
Example
value
): void
SetTimeout sets read/write timeout for the connection (in seconds).
Name | Type |
---|---|
value | number |
void
Example