Skip to content

DenoSocketServer

Native Deno TCP and Unix socket servers for Effect's unstable socket server API.

The plain make and layer names intentionally differ from DenoSocket.makeTcp and DenoSocket.layerTcp because this module has only one server kind. Deno has no standalone WebSocket server, so WebSocket constructors are omitted, and there is no IncomingMessage analogue. Connections made before run starts remain in the kernel backlog instead of being accepted and buffered as they are by the Node implementation. A second concurrent run waits for the first because listener access is guarded by a semaphore.

Deno-native TLS server constructors are included even though the Node socket server has no corresponding dedicated constructors. TLS is deliberately not tested here because the repository has no certificate fixture.

6 exports Added in v4.0.0 Source

Constructors

make

Added in v4.0.0 Source

Creates a scoped socket server using a native Deno TCP or Unix listener.

Signature

declare const make: (
options: ListenOptions,
) => Effect.Effect<
SocketServer.SocketServer["Service"],
SocketServer.SocketServerError,
Scope.Scope
>;

makeTls

Added in v4.0.0 Source

Creates a scoped TLS socket server using a native Deno TLS listener.

Signature

declare const makeTls: (
options: TlsListenOptions,
) => Effect.Effect<
SocketServer.SocketServer["Service"],
SocketServer.SocketServerError,
Scope.Scope
>;

Layers

layer

Added in v4.0.0 Source

Provides a socket server using a scoped native Deno TCP or Unix listener.

Signature

declare const layer: (
options: ListenOptions,
) => Layer.Layer<SocketServer.SocketServer, SocketServer.SocketServerError>;

layerTls

Added in v4.0.0 Source

Provides a TLS socket server using a scoped native Deno TLS listener.

Signature

declare const layerTls: (
options: TlsListenOptions,
) => Layer.Layer<SocketServer.SocketServer, SocketServer.SocketServerError>;

Models

ListenOptions type

Added in v4.0.0 Source

Native Deno options for listening on a TCP or Unix socket.

Signature

type ListenOptions =
| (Deno.TcpListenOptions & {
transport?: "tcp";
})
| (Deno.UnixListenOptions & {
transport: "unix";
});

TlsListenOptions type

Added in v4.0.0 Source

Native Deno options and certified key material for listening with TLS.

Signature

type TlsListenOptions = Deno.ListenTlsOptions & Deno.TlsCertifiedKeyPem;