SocketServer
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.
Errors
SocketServerError
Tagged socket server error that wraps a server error reason and exposes its cause.
Signature
declare class SocketServerError extends YieldableError<this> & { readonly _tag: "SocketServerError";} & Readonly<{ readonly reason: SocketServerErrorReason;}> { constructor(props: { readonly reason: SocketServerErrorReason; }); readonly "@effect/platform/SocketServer/SocketServerError": "@effect/platform/SocketServer/SocketServerError"; message: string;}SocketServerErrorReason type
Union of socket server error reasons.
Signature
type SocketServerErrorReason = SocketServerOpenError | SocketServerUnknownErrorSocketServerOpenError
Error reason for failures that occur while opening a socket server.
Signature
declare class SocketServerOpenError extends YieldableError<this> & { readonly _tag: "SocketServerOpenError";} & Readonly<{ readonly cause: unknown;}> { constructor(args: { readonly cause: unknown; }); message: string;}SocketServerUnknownError
Error reason for uncategorized socket server failures.
Signature
declare class SocketServerUnknownError extends YieldableError<this> & { readonly _tag: "SocketServerUnknownError";} & Readonly<{ readonly cause: unknown;}> { constructor(args: { readonly cause: unknown; }); message: string;}Models
Socket server address, either a TCP host and port or a Unix socket path.
Signature
type Address = UnixAddress | TcpAddressTcpAddress interface
TCP socket server address with hostname and port.
Signature
interface TcpAddress { readonly _tag: "TcpAddress"; readonly hostname: string; readonly port: number;}UnixAddress interface
Unix socket server address identified by a filesystem path.
Signature
interface UnixAddress { readonly _tag: "UnixAddress"; readonly path: string;}Services
SocketServer
Context service for a socket server, exposing its bound address and a run
loop that handles each accepted Socket.
Signature
declare class SocketServer extends Shape<"@effect/platform/SocketServer", { readonly address: Address; readonly run: <R, E, _>(handler: (socket: Socket) => Effect<_, E, R>) => Effect<never, SocketServerError, R>;}, this> { constructor(_: never);}Type IDs
ErrorTypeId
Runtime type identifier attached to SocketServerError values.
Signature
declare const ErrorTypeId: ErrorTypeIdErrorTypeId type
Type-level identifier used to mark SocketServerError values.
Signature
type ErrorTypeId = "@effect/platform/SocketServer/SocketServerError"