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

# Class: DebuggerSocket

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

One TCP connection to the extension, framed in both directions.

## Constructors

### Constructor

> **new DebuggerSocket**(`socket`): `DebuggerSocket`

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

Wraps a connected socket.

#### Parameters

##### socket

`Socket`

#### Returns

`DebuggerSocket`

## Accessors

### closed

#### Get Signature

> **get** **closed**(): `boolean`

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

Whether the connection has closed.

##### Returns

`boolean`

***

### peer

#### Get Signature

> **get** **peer**(): `object`

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

The extension's end of the connection: its IP address and port.

##### Returns

`object`

###### address

> `readonly` **address**: `string`

###### port

> `readonly` **port**: `number`

## Methods

### close()

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

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

Closes the connection once what was sent has gone. It ends this side and keeps reading until
the extension closes its own, which it does on seeing the end. Destroying the socket at once
would close it with the extension's last frames unread, and the reset that sends can make the
extension discard what arrived just before it, such as the line saying why the handshake
was refused. A peer that keeps its own side open is cut off after `CLOSE_GRACE_MS`.

#### Returns

`void`

***

### onClose()

> **onClose**(`listener`): `void`

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

Calls `listener` once when the connection closes, with the error that closed it if any.

#### Parameters

##### listener

(`error`) => `void`

#### Returns

`void`

***

### onMessage()

> **onMessage**(`listener`): `void`

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

Calls `listener` with each message the extension sends, in order.

#### Parameters

##### listener

(`message`) => `void`

#### Returns

`void`

***

### send()

> **send**(`message`): `void`

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

Sends one message.

#### Parameters

##### message

`unknown`

#### Returns

`void`
