> ## Documentation Index
> Fetch the complete documentation index at: https://projectdiscovery-subfinder-reference-blog.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Net

<a name="module_net" />

## net

* [net](#module_net)
  * [`NetConn`](#module_net..NetConn)
    * [`.Close()`](#module_net..NetConn+Close)
    * [`.Recv([N])`](#module_net..NetConn+Recv) ⇒ <code>Uint8Array</code>
    * [`.RecvHex([N])`](#module_net..NetConn+RecvHex) ⇒ <code>string</code>
    * [`.RecvString([N])`](#module_net..NetConn+RecvString) ⇒ <code>string</code>
    * [`.Send(data)`](#module_net..NetConn+Send)
    * [`.SendArray(data)`](#module_net..NetConn+SendArray)
    * [`.SendHex(data)`](#module_net..NetConn+SendHex)
    * [`.SetTimeout(value)`](#module_net..NetConn+SetTimeout)
  * [`Open(protocol, address)`](#module_net..Open) ⇒ <code>NetConn</code>
  * [`OpenTLS(protocol, address)`](#module_net..OpenTLS) ⇒ <code>NetConn</code>

<a name="module_net..NetConn" />

### (net).NetConn

NetConn is a connection to a remote host.

**Kind**: inner class of [<code>net</code>](#module_net)

* [`NetConn`](#module_net..NetConn)
  * [`.Close()`](#module_net..NetConn+Close)
  * [`.Recv([N])`](#module_net..NetConn+Recv) ⇒ <code>Uint8Array</code>
  * [`.RecvHex([N])`](#module_net..NetConn+RecvHex) ⇒ <code>string</code>
  * [`.RecvString([N])`](#module_net..NetConn+RecvString) ⇒ <code>string</code>
  * [`.Send(data)`](#module_net..NetConn+Send)
  * [`.SendArray(data)`](#module_net..NetConn+SendArray)
  * [`.SendHex(data)`](#module_net..NetConn+SendHex)
  * [`.SetTimeout(value)`](#module_net..NetConn+SetTimeout)

<a name="module_net..NetConn+Close" />

#### netConn.Close()

Close closes the connection.

**Kind**: instance method of [<code>NetConn</code>](#module_net..NetConn)\
**Throws**:

* <code>error</code> - The error encountered during connection closing.

**Example**

```js
let m = require('nuclei/net');
let c = m.Open('tcp', 'localhost:8080');
c.Close();
```

<a name="module_net..NetConn+Recv" />

#### netConn.Recv(\[N]) ⇒ <code>Uint8Array</code>

Recv receives data from the connection with a timeout. If N is 0, it will read all available data.

**Kind**: instance method of [<code>NetConn</code>](#module_net..NetConn)\
**Returns**: <code>Uint8Array</code> - - The received data in an array.\
**Throws**:

* <code>error</code> - The error encountered during data receiving.

| Param | Type                | Default        | Description                     |
| ----- | ------------------- | -------------- | ------------------------------- |
| \[N]  | <code>number</code> | <code>0</code> | The number of bytes to receive. |

**Example**

```js
let m = require('nuclei/net');
let c = m.Open('tcp', 'localhost:8080');
let data = c.Recv(1024);
```

<a name="module_net..NetConn+RecvHex" />

#### netConn.RecvHex(\[N]) ⇒ <code>string</code>

RecvHex receives data from the connection with a timeout in hex format. If N is 0, it will read all available data.

**Kind**: instance method of [<code>NetConn</code>](#module_net..NetConn)\
**Returns**: <code>string</code> - - The received data in hex format.\
**Throws**:

* <code>error</code> - The error encountered during data receiving.

| Param | Type                | Default        | Description                     |
| ----- | ------------------- | -------------- | ------------------------------- |
| \[N]  | <code>number</code> | <code>0</code> | The number of bytes to receive. |

**Example**

```js
let m = require('nuclei/net');
let c = m.Open('tcp', 'localhost:8080');
let data = c.RecvHex(1024);
```

<a name="module_net..NetConn+RecvString" />

#### netConn.RecvString(\[N]) ⇒ <code>string</code>

RecvString receives data from the connection with a timeout. Output is returned as a string. If N is 0, it will read all available data.

**Kind**: instance method of [<code>NetConn</code>](#module_net..NetConn)\
**Returns**: <code>string</code> - - The received data as a string.\
**Throws**:

* <code>error</code> - The error encountered during data receiving.

| Param | Type                | Default        | Description                     |
| ----- | ------------------- | -------------- | ------------------------------- |
| \[N]  | <code>number</code> | <code>0</code> | The number of bytes to receive. |

**Example**

```js
let m = require('nuclei/net');
let c = m.Open('tcp', 'localhost:8080');
let data = c.RecvString(1024);
```

<a name="module_net..NetConn+Send" />

#### netConn.Send(data)

Send sends data to the connection with a timeout.

**Kind**: instance method of [<code>NetConn</code>](#module_net..NetConn)\
**Throws**:

* <code>error</code> - The error encountered during data sending.

| Param | Type                    | Description       |
| ----- | ----------------------- | ----------------- |
| data  | <code>Uint8Array</code> | The data to send. |

**Example**

```js
let m = require('nuclei/net');
let c = m.Open('tcp', 'localhost:8080');
c.Send(new Uint8Array([1, 2, 3]));
```

<a name="module_net..NetConn+SendArray" />

#### netConn.SendArray(data)

SendArray sends array data to connection.

**Kind**: instance method of [<code>NetConn</code>](#module_net..NetConn)\
**Throws**:

* <code>error</code> - The error encountered during data sending.

| Param | Type                    | Description             |
| ----- | ----------------------- | ----------------------- |
| data  | <code>Uint8Array</code> | The array data to send. |

**Example**

```js
let m = require('nuclei/net');
let c = m.Open('tcp', 'localhost:8080');
c.SendArray(new Uint8Array([1, 2, 3]));
```

<a name="module_net..NetConn+SendHex" />

#### netConn.SendHex(data)

SendHex sends hex data to connection.

**Kind**: instance method of [<code>NetConn</code>](#module_net..NetConn)\
**Throws**:

* <code>error</code> - The error encountered during data sending.

| Param | Type                | Description           |
| ----- | ------------------- | --------------------- |
| data  | <code>string</code> | The hex data to send. |

**Example**

```js
let m = require('nuclei/net');
let c = m.Open('tcp', 'localhost:8080');
c.SendHex('0x123');
```

<a name="module_net..NetConn+SetTimeout" />

#### netConn.SetTimeout(value)

SetTimeout sets read/write timeout for the connection (in seconds).

**Kind**: instance method of [<code>NetConn</code>](#module_net..NetConn)

| Param | Type                | Description                   |
| ----- | ------------------- | ----------------------------- |
| value | <code>number</code> | The timeout value in seconds. |

**Example**

```js
let m = require('nuclei/net');
let c = m.Open('tcp', 'localhost:8080');
c.SetTimeout(5);
```

<a name="module_net..Open" />

### (net).Open(protocol, address) ⇒ <code>NetConn</code>

Open opens a new connection to the address with a timeout. Supported protocols: tcp, udp.

**Kind**: inner method of [<code>net</code>](#module_net)\
**Returns**: <code>NetConn</code> - - The NetConn object representing the connection.\
**Throws**:

* <code>error</code> - The error encountered during connection opening.

| Param    | Type                | Description                |
| -------- | ------------------- | -------------------------- |
| protocol | <code>string</code> | The protocol to use.       |
| address  | <code>string</code> | The address to connect to. |

**Example**

```js
let m = require('nuclei/net'); 
let conn = m.Open('tcp', 'localhost:8080');
```

<a name="module_net..OpenTLS" />

### (net).OpenTLS(protocol, address) ⇒ <code>NetConn</code>

OpenTLS opens a new connection to the address with a timeout. Supported protocols: tcp, udp.

**Kind**: inner method of [<code>net</code>](#module_net)\
**Returns**: <code>NetConn</code> - - The NetConn object representing the connection.\
**Throws**:

* <code>error</code> - The error encountered during connection opening.

| Param    | Type                | Description                |
| -------- | ------------------- | -------------------------- |
| protocol | <code>string</code> | The protocol to use.       |
| address  | <code>string</code> | The address to connect to. |

**Example**

```js
let m = require('nuclei/net'); 
let conn = m.OpenTLS('tcp', 'localhost:8080');
```
