Skip to content

@halone/sdk / TcpSocket

Class: TcpSocket ​

A TCP connection through the shell; needs the network.tcp permission.

Properties ​

id ​

ts
readonly id: number;

Accessors ​

closed ​

Get Signature ​

ts
get closed(): boolean;
Returns ​

boolean

Methods ​

close() ​

ts
close(): Promise<void>;

Returns ​

Promise<void>


onClose() ​

ts
onClose(listener): () => void;

Parameters ​

listener ​

(error) => void

Returns ​

() => void


onData() ​

ts
onData(listener): () => void;

Parameters ​

listener ​

(bytes) => void

Returns ​

() => void


write() ​

ts
write(data): Promise<void>;

Resolves once the bytes are handed to the network, which is the signal to send more.

Parameters ​

data ​

string | Uint8Array<ArrayBufferLike>

Returns ​

Promise<void>


connect() ​

ts
static connect(
   connection, 
   host, 
   port, 
   options?
): Promise<TcpSocket>;

Parameters ​

connection ​

Connection

host ​

string

port ​

number

options? ​

SocketOptions

Returns ​

Promise<TcpSocket>

Released under the MIT License.