(net socket) - Modern Socket library

Library (net socket)

Providing, probably, modern socket library.

Most of the bindings defined in this library is identical as (sagittarius socket), so this document will describe only the differences.

Function socket-options? o
Function tls-socket-options? o
Function server-tls-socket-options? o

Returns #t if the given o is a socket-options, tls-socket-options, or server-tls-socket-options, respectively.

The socket-options? returns #t for all 3 types.

Macro socket-options-builder (fields ... )

Builds a socket-options object. The field must be one or multiple of the followings:

ai-family

See ai-family of (sagittarius socket)

ai-socktype

See ai-socktype of (sagittarius socket)

ai-flags

See ai-flags of (sagittarius socket)

ai-protocol

See ai-protocl of (sagittarius socket)

non-blocking?

Specifies if the socket is non blocking or not, default #t

connection-timeout

Specifies connection timeout in micro seconds, default #f (infinite)

read-timeout

Specifies read timeout, default #f (infinite) see socket-set-read-timeout! for more details.

Macro tls-socket-options-builder (fields ... )

Builds a tls-socket-options object. The fields must be the ones from socket-options-builder or one or multiple of the followings:

handshake

Specifes if handshake must be done or not. Default #t

private-key

A client private key

certificates

A list of client certificates, must be specified when private-key is specified

certificate-verifier

A certificate verifier procedure

sni*

A list of server name indicators, a list of string

alpn*

A list of application layer protocol negotiation names

Macro server-tls-socket-options-builder (fields ... )

Builds a server-tls-socket-options object. The fields must be the ones from tls-socket-options-builder or one or multiple of the followings:

client-certificate-required?

Specifes if client certificate is required or not. Default #f

trusted-certificates

A list of trusted certificates

Function make-client-socket node service :optional options

Creates a client socket. This is almost the same as the one from (sagittarius socket), the only difference is it takes options to specify extra options, such as read timeout or connection timeout.

Function make-client-tls-socket node service :optional options

Creates a client socket. This is almost the same as the one from (rfc tls), the only difference is it takes options to specify extra options, such as client certificate, alpn, etc.

Function make-server-socket node service :optional options

Creates a client socket. This is almost the same as the one from (sagittarius socket), the only difference is it takes options to specify extra options, such as read timeout or connection timeout.

Function make-server-tls-socket node service :optional options

Creates a client socket. This is almost the same as the one from (rfc tls), the only difference is it takes options to specify extra options, such as private key, etc.

Function socket-options->client-socket options node service

Creates a client socket from the given options, node and service.

This is a convenient procedure to make a socket from the options instead of let user dispatch manually.