Net.NetConn
Class: NetConn
net.NetConn
NetConn is a connection to a remote host. this is returned/create by Open and OpenTLS functions.
Example
const net = require('nuclei/net');
const conn = net.Open('tcp', 'acme.com:80');
Table of contents
Constructors
Methods
Constructors
constructor
• new NetConn(): NetConn
Returns
Defined in
net.ts:46
Methods
Close
▸ Close(): void
Close closes the connection.
Returns
void
Example
const net = require('nuclei/net');
const conn = net.Open('tcp', 'acme.com:80');
conn.Close();
Defined in
net.ts:56
Recv
▸ Recv(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.
Parameters
Name | Type |
---|---|
N | number |
Returns
Uint8Array
Example
const net = require('nuclei/net');
const conn = net.Open('tcp', 'acme.com:80');
const data = conn.Recv(1024);
log(`Received ${data.length} bytes from the server`)
Defined in
net.ts:146
RecvFull
▸ RecvFull(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.
Parameters
Name | Type |
---|---|
N | number |
Returns
Uint8Array
Example
const net = require('nuclei/net');
const conn = net.Open('tcp', 'acme.com:80');
const data = conn.RecvFull(1024);
Defined in
net.ts:128
RecvFullHex
▸ RecvFullHex(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.
Parameters
Name | Type |
---|---|
N | number |
Returns
string
Example
const net = require('nuclei/net');
const conn = net.Open('tcp', 'acme.com:80');
const data = conn.RecvFullHex(1024);
Defined in
net.ts:196
RecvFullString
▸ RecvFullString(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.
Parameters
Name | Type |
---|---|
N | number |
Returns
string
Example
const net = require('nuclei/net');
const conn = net.Open('tcp', 'acme.com:80');
const data = conn.RecvFullString(1024);
Defined in
net.ts:162
RecvHex
▸ RecvHex(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.
Parameters
Name | Type |
---|---|
N | number |
Returns
string
Example
const net = require('nuclei/net');
const conn = net.Open('tcp', 'acme.com:80');
const data = conn.RecvHex(1024);
Defined in
net.ts:213
RecvString
▸ RecvString(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.
Parameters
Name | Type |
---|---|
N | number |
Returns
string
Example
const net = require('nuclei/net');
const conn = net.Open('tcp', 'acme.com:80');
const data = conn.RecvString(1024);
Defined in
net.ts:179
Send
▸ Send(data
): void
Send sends data to the connection with a timeout.
Parameters
Name | Type |
---|---|
data | string |
Returns
void
Example
const net = require('nuclei/net');
const conn = net.Open('tcp', 'acme.com:80');
conn.Send('hello');
Defined in
net.ts:112
SendArray
▸ SendArray(data
): void
SendArray sends array data to connection
Parameters
Name | Type |
---|---|
data | any |
Returns
void
Example
const net = require('nuclei/net');
const conn = net.Open('tcp', 'acme.com:80');
conn.SendArray(['hello', 'world']);
Defined in
net.ts:84
SendHex
▸ SendHex(data
): void
SendHex sends hex data to connection
Parameters
Name | Type |
---|---|
data | string |
Returns
void
Example
const net = require('nuclei/net');
const conn = net.Open('tcp', 'acme.com:80');
conn.SendHex('68656c6c6f');
Defined in
net.ts:98
SetTimeout
▸ SetTimeout(value
): void
SetTimeout sets read/write timeout for the connection (in seconds).
Parameters
Name | Type |
---|---|
value | number |
Returns
void
Example
const net = require('nuclei/net');
const conn = net.Open('tcp', 'acme.com:80');
conn.SetTimeout(10);
Defined in
net.ts:70
Was this page helpful?