2023-01-12 17:50:38 +00:00
|
|
|
import { Duplex, DuplexEvents, Callback } from "streamx";
|
|
|
|
type AddressFamily = "IPv6" | "IPv4";
|
2023-04-16 02:17:57 +00:00
|
|
|
export interface SocketOptions {
|
2023-01-12 17:50:38 +00:00
|
|
|
allowHalfOpen?: boolean;
|
|
|
|
remoteAddress?: string;
|
|
|
|
remotePort?: number;
|
2023-02-25 01:04:45 +00:00
|
|
|
remotePublicKey?: Uint8Array;
|
2023-01-12 17:50:38 +00:00
|
|
|
write?: (this: Duplex<any, any, any, any, true, true, DuplexEvents<any, any>>, data: any, cb: Callback) => void;
|
2023-02-26 03:10:17 +00:00
|
|
|
emulateWebsocket?: boolean;
|
2023-01-12 17:50:38 +00:00
|
|
|
}
|
|
|
|
export default class Socket extends Duplex {
|
|
|
|
private _allowHalfOpen;
|
|
|
|
remoteAddress: any;
|
|
|
|
remotePort: any;
|
|
|
|
remoteFamily: AddressFamily;
|
|
|
|
bufferSize: any;
|
2023-02-06 15:52:26 +00:00
|
|
|
readable: true;
|
|
|
|
writable: true;
|
2023-02-25 01:04:45 +00:00
|
|
|
remotePublicKey: Uint8Array;
|
2023-02-26 03:10:17 +00:00
|
|
|
private _emulateWebsocket;
|
2023-02-26 03:49:50 +00:00
|
|
|
addEventListener?: typeof this.addListener;
|
|
|
|
removeEventListener?: typeof this.removeListener;
|
|
|
|
send?: typeof this.write;
|
|
|
|
close?: typeof this.end;
|
2023-02-26 03:10:17 +00:00
|
|
|
constructor({ allowHalfOpen, remoteAddress, remotePort, remotePublicKey, write, emulateWebsocket, }?: SocketOptions);
|
2023-01-12 17:50:38 +00:00
|
|
|
private _connecting;
|
|
|
|
get connecting(): boolean;
|
2023-02-26 03:38:46 +00:00
|
|
|
get readyState(): string | number;
|
2023-01-12 17:50:38 +00:00
|
|
|
listen(): void;
|
|
|
|
setTimeout(msecs: any, callback: any): void;
|
|
|
|
_onTimeout(): void;
|
|
|
|
setNoDelay(enable: boolean): void;
|
|
|
|
setKeepAlive(setting: any, msecs: number): void;
|
|
|
|
address(): {
|
|
|
|
address: any;
|
|
|
|
port: any;
|
|
|
|
family: AddressFamily;
|
|
|
|
};
|
|
|
|
static isIP(input: string): number;
|
|
|
|
static isIPv4(input: string): boolean;
|
|
|
|
static isIPv6(input: string): boolean;
|
|
|
|
}
|
|
|
|
export {};
|