NodeSocket
Node socket adapters for Effect sockets.
This module opens node:net connections or wraps existing Node Duplex streams and presents them as Socket.Socket values, socket channels, or layers. It also exposes the current underlying NetSocket service for code running inside a socket handler and re-exports the ws package namespace.
Constructors
fromDuplex
Added in v4.0.0
Source
Signature
declare function fromDuplex<RO>( open: Effect<Duplex, SocketError, RO>, options?: { readonly openTimeout?: Input; },): Effect<Socket, never, Exclude<RO, Scope>>;Opens a Node TCP connection as an Effect socket.
When to use
Use to create a scoped Socket.Socket from Node net.createConnection.
Details
Supports openTimeout and closes or destroys the underlying socket when the enclosing scope is finalized.
Signature
declare function makeNet(options: any): Effect<Socket>;makeNetChannel
Added in v4.0.0
Source
Creates a Channel over a TCP socket, reading arrays of Uint8Array chunks and writing arrays of bytes, strings, or socket close events.
Signature
declare function makeNetChannel<IE = never>( options: NetConnectOpts,): Channel< readonly [Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBufferLike>], SocketError | IE, void, readonly [ string | Uint8Array<ArrayBufferLike> | CloseEvent, string | Uint8Array<ArrayBufferLike> | CloseEvent, ], IE>;Layers
Re-Exports
NodeWS
Added in v4.0.0
Signature
declare const NodeWS: any;
Adapts a Node
Duplexinto aSocket.Socket, wiring data events to socket handlers, providing a scoped writer, and mapping open, read, write, and close failures toSocketError.