SocketServer.ts
SocketServer.ts overview
Section titled “SocketServer.ts overview”Service contract for servers that accept socket connections.
SocketServer exposes the bound server address and a long-running run
loop that hands each accepted connection to a handler as a Socket.Socket.
The module also defines TCP and Unix socket address models plus the
server-level errors reported while opening or running a server. Platform
layers provide concrete implementations of this service.
Since v4.0.0
Exports Grouped by Category
Section titled “Exports Grouped by Category”errors
Section titled “errors”SocketServerError (class)
Section titled “SocketServerError (class)”Tagged socket server error that wraps a server error reason and exposes its cause.
Signature
declare class SocketServerError { constructor(props: { readonly reason: SocketServerErrorReason })}Since v4.0.0
[ErrorTypeId] (property)
Section titled “[ErrorTypeId] (property)”Marks this value as a socket server error for runtime guards.
Signature
readonly [ErrorTypeId]: "@effect/platform/SocketServer/SocketServerError"Since v4.0.0
SocketServerErrorReason (type alias)
Section titled “SocketServerErrorReason (type alias)”Union of socket server error reasons.
Signature
type SocketServerErrorReason = SocketServerOpenError | SocketServerUnknownErrorSince v4.0.0
SocketServerOpenError (class)
Section titled “SocketServerOpenError (class)”Error reason for failures that occur while opening a socket server.
Signature
declare class SocketServerOpenErrorSince v4.0.0
SocketServerUnknownError (class)
Section titled “SocketServerUnknownError (class)”Error reason for uncategorized socket server failures.
Signature
declare class SocketServerUnknownErrorSince v4.0.0
models
Section titled “models”Address (type alias)
Section titled “Address (type alias)”Socket server address, either a TCP host and port or a Unix socket path.
Signature
type Address = UnixAddress | TcpAddressSince v4.0.0
TcpAddress (interface)
Section titled “TcpAddress (interface)”TCP socket server address with hostname and port.
Signature
export interface TcpAddress { readonly _tag: "TcpAddress" readonly hostname: string readonly port: number}Since v4.0.0
UnixAddress (interface)
Section titled “UnixAddress (interface)”Unix socket server address identified by a filesystem path.
Signature
export interface UnixAddress { readonly _tag: "UnixAddress" readonly path: string}Since v4.0.0
services
Section titled “services”SocketServer (class)
Section titled “SocketServer (class)”Context service for a socket server, exposing its bound address and a run
loop that handles each accepted Socket.
Signature
declare class SocketServerSince v4.0.0
type IDs
Section titled “type IDs”ErrorTypeId
Section titled “ErrorTypeId”Runtime type identifier attached to SocketServerError values.
Signature
declare const ErrorTypeId: "@effect/platform/SocketServer/SocketServerError"Since v4.0.0
ErrorTypeId (type alias)
Section titled “ErrorTypeId (type alias)”Type-level identifier used to mark SocketServerError values.
Signature
type ErrorTypeId = "@effect/platform/SocketServer/SocketServerError"Since v4.0.0