[API reference](https://jsprismarine.dev/api/index.md) / [@jsprismarine/script-host](https://jsprismarine.dev/api/@jsprismarine/script-host/index.md) / debugger/transport

# debugger/transport

## Classes

- [DebuggerSocket](https://jsprismarine.dev/api/@jsprismarine/script-host/debugger/transport/classes/DebuggerSocket.md)

## Interfaces

### ConnectOptions

Defined in: [script-host/src/debugger/transport.ts:190](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/debugger/transport.ts#L190)

Where an extension in `listen` mode waits.

#### Properties

##### host?

> `readonly` `optional` **host?**: `string`

Defined in: [script-host/src/debugger/transport.ts:191](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/debugger/transport.ts#L191)

##### port?

> `readonly` `optional` **port?**: `number`

Defined in: [script-host/src/debugger/transport.ts:192](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/debugger/transport.ts#L192)

***

### DebuggerListener

Defined in: [script-host/src/debugger/transport.ts:144](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/debugger/transport.ts#L144)

A listener waiting for the extension to connect. It takes one connection, then stops listening.

#### Properties

##### address

> `readonly` **address**: `AddressInfo`

Defined in: [script-host/src/debugger/transport.ts:146](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/debugger/transport.ts#L146)

The address and port it listens on, which tells the port when 0 asked for any.

##### connection

> `readonly` **connection**: `Promise`\<[`DebuggerSocket`](https://jsprismarine.dev/api/@jsprismarine/script-host/debugger/transport/classes/DebuggerSocket.md)\>

Defined in: [script-host/src/debugger/transport.ts:148](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/debugger/transport.ts#L148)

The connection, once the extension makes it; rejected when the listener closes first.

#### Methods

##### close()

> **close**(): `void`

Defined in: [script-host/src/debugger/transport.ts:150](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/debugger/transport.ts#L150)

Stops waiting.

###### Returns

`void`

***

### ListenOptions

Defined in: [script-host/src/debugger/transport.ts:137](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/debugger/transport.ts#L137)

Where to listen for the extension, and the passcode a non-loopback address requires.

#### Properties

##### address?

> `readonly` `optional` **address?**: `string`

Defined in: [script-host/src/debugger/transport.ts:139](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/debugger/transport.ts#L139)

##### passcode?

> `readonly` `optional` **passcode?**: `string`

Defined in: [script-host/src/debugger/transport.ts:140](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/debugger/transport.ts#L140)

##### port?

> `readonly` `optional` **port?**: `number`

Defined in: [script-host/src/debugger/transport.ts:138](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/debugger/transport.ts#L138)

## Variables

### DEFAULT\_LISTEN\_ADDRESS

> `const` **DEFAULT\_LISTEN\_ADDRESS**: `"127.0.0.1"` = `'127.0.0.1'`

Defined in: [script-host/src/debugger/transport.ts:18](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/debugger/transport.ts#L18)

The address a listener binds when none is given, as `script-debugger-listen-address` defaults.

## Functions

### checkListenAddress()

> **checkListenAddress**(`address`, `passcode`): `void`

Defined in: [script-host/src/debugger/transport.ts:40](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/debugger/transport.ts#L40)

Applies Bedrock Dedicated Server's rule for listeners: one on an address other machines can reach
needs a passcode.

#### Parameters

##### address

`string`

##### passcode

`string` \| `undefined`

#### Returns

`void`

#### Throws

With the server's message when the address is not loopback and the passcode is empty.

***

### connectToDebugger()

> **connectToDebugger**(`options?`): `Promise`\<[`DebuggerSocket`](https://jsprismarine.dev/api/@jsprismarine/script-host/debugger/transport/classes/DebuggerSocket.md)\>

Defined in: [script-host/src/debugger/transport.ts:199](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/debugger/transport.ts#L199)

Connects to an extension that listens, as `/script debugger connect` does.

#### Parameters

##### options?

[`ConnectOptions`](#connectoptions) = `{}`

#### Returns

`Promise`\<[`DebuggerSocket`](https://jsprismarine.dev/api/@jsprismarine/script-host/debugger/transport/classes/DebuggerSocket.md)\>

#### Throws

When the connection fails.

***

### isLoopbackAddress()

> **isLoopbackAddress**(`address`): `boolean`

Defined in: [script-host/src/debugger/transport.ts:24](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/debugger/transport.ts#L24)

Whether an address only reaches this machine: `localhost`, `127.0.0.0/8`, `::1`, or an IPv4
loopback address mapped into IPv6.

#### Parameters

##### address

`string`

#### Returns

`boolean`

***

### listenForDebugger()

> **listenForDebugger**(`options?`): `Promise`\<[`DebuggerListener`](#debuggerlistener)\>

Defined in: [script-host/src/debugger/transport.ts:157](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/debugger/transport.ts#L157)

Listens for the extension, as `/script debugger listen` does.

#### Parameters

##### options?

[`ListenOptions`](#listenoptions) = `{}`

#### Returns

`Promise`\<[`DebuggerListener`](#debuggerlistener)\>

#### Throws

When the address is not loopback and no passcode is set, or it cannot listen.
