A base interface for both ITcpSocket and IUdpSocket objects.
interface ISocket {
// Methods
${connect}(host: string, port: string): Promise<void>;
${close}(): void;
${send}(text: string, encoding: ${Common.Encoding} | number): Promise<number>;
${send#send1}(byte: number): Promise<number>;
${send#send2}(bytes: number[] | Uint8Array | Uint16Array | Uint32Array | ArrayBuffer | DataView): Promise<number>;
${receive}(): Promise<Uint8Array>;
}
// This interface is not available in managed environment
// This interface is not available in native environment
connect(host: string, port: string): Promise<void>;
// This method is not available in managed environment
// This method is not available in native environment
host
port
Connects the socket to the remote endpoint.
close(): void;
// This method is not available in managed environment
// This method is not available in native environment
Closes the active connection.
send(text: string, encoding: ${Common.Encoding} | number): Promise<number>;
// This method is not available in managed environment
// This method is not available in native environment
text
:
encoding
Common.Encoding.Utf8
.The number of bytes sent to the network.
A string to send
Send the given string encoded using the specified encoding to the socket.
send(byte: number): Promise<number>;
// This method is not available in managed environment
// This method is not available in native environment
byte
The number of bytes sent to the network.
Send a single byte to the network.
send(bytes: number[] | Uint8Array | Uint16Array | Uint32Array | ArrayBuffer | DataView): Promise<number>;
// This method is not available in managed environment
// This method is not available in native environment
bytes
DataView
object.The number of bytes sent to the network.
receive(): Promise<Uint8Array>;
// This method is not available in managed environment
// This method is not available in native environment
A byte array with data received from a socket.
Receive data from a socket.