Module

Node.Net.Server

#Address

type Address = { address :: String, family :: String, port :: Int }

#ListenOptions

data ListenOptions

Options to configure the listening side of a Server. These options decide whether the Server is ICP or TCP.

One of path or port must be set. Setting path will make the Server ICP. Setting port will make the Server TCP.

#Server

data Server :: Type

An ICP or TCP server.

#ServerOptions

data ServerOptions

Options to configure the basics of a Server.

#address

address :: Server -> Effect (Maybe (Either Address String))

Attempts to return the bound address of a Server.

If the Server is not listening, Nothing is returned. If the Server is ICP, it will return a String. If the Server is TCP, it will return an Address.

#close

close :: Server -> (Maybe Error -> Effect Unit) -> Effect Unit

Closes the Server and invokes the callback after the 'close' event is emitted. An Error is passed to the callback if the Server was not open.

#createServer

createServer :: Options ServerOptions -> (Socket -> Effect Unit) -> Effect Server

Creates an ICP or TCP Server, returns the Server, and adds the callback as a listenter for the 'connection' event. the Server will be ICP or TCP depending on what it listens to.

#getConnections

getConnections :: Server -> (Either Error Int -> Effect Unit) -> Effect Unit

Returns the number of concurrent connections to the Server.

#listen

listen :: Server -> Options ListenOptions -> Effect Unit -> Effect Unit

Starts the Server as an ICP or TCP Server listening for connections, adds the callback as a listener to the 'listening' event, and emits the 'listening' event.

#listenBacklog

listenBacklog :: Option ListenOptions Int

Maximum number of pending connections. Defaults to 511.

#listenExclusive

listenExclusive :: Option ListenOptions Boolean

When true, the handle cannot be shared and will result in an error. When false, the handle can be shared. Defaults to false.

#listenHost

listenHost :: Option ListenOptions String

The host to configure TCP Servers.

Determines the host the Server will attempt to listen on. Defaults to IPv6 :: if available, and IPv4 0.0.0.0 otherwise.

#listenICP

listenICP :: Server -> String -> Int -> Effect Unit -> Effect Unit

Starts the Server as an ICP Server listening for connections, adds the callback as a listener to the 'listening' event, and emits the 'listening' event.

#listenIpv6Only

listenIpv6Only :: Option ListenOptions Boolean

When true, only binds to IPv6 hosts and not also to IPv4 hosts. Defaults to false.

#listenPath

listenPath :: Option ListenOptions String

The path to configure ICP Servers.

Determines the ICP endpoint the Server will attempt to listen on.

#listenPort

listenPort :: Option ListenOptions Int

The port to configure TCP Servers.

Determines the TCP endpoint the Server will attempt to listen on. When 0, the OS will assign an arbitrary port.

#listenReadableAll

listenReadableAll :: Option ListenOptions Boolean

Makes the ICP pipe readable for all users. Defaults to false.

#listenTCP

listenTCP :: Server -> Int -> String -> Int -> Effect Unit -> Effect Unit

Starts the Server as a TCP Server listening for connections, adds the callback as a listener to the 'listening' event, and emits the 'listening' event.

#listenWritableAll

listenWritableAll :: Option ListenOptions Boolean

Makes the ICP pipe writable for all users. Defaults to false.

#listening

listening :: Server -> Effect Boolean

Returns true if the Server is listening for connections, and false otherwise.

#onClose

onClose :: Server -> Effect Unit -> Effect Unit

Attaches the callback as a listener to the 'close' event.

'close' is emitted when a close occurs. Will not be emitted until all connections have ended.

#onConnection

onConnection :: Server -> (Socket -> Effect Unit) -> Effect Unit

Attaches the callback as a listener to the 'connection' event.

'connection' is emitted when a new connection is made.

#onError

onError :: Server -> (Error -> Effect Unit) -> Effect Unit

Attaches the callback as a listener to the 'error' event.

'error' is emitted when an error occurs.

#onListening

onListening :: Server -> Effect Unit -> Effect Unit

Attaches the callback as a listener to the 'listening' event.

'listening' is emitted when the Server has been bound.

#serverAllowHalfOpen

serverAllowHalfOpen :: Option ServerOptions Boolean

Allows half open TCP connections. Defaults to false.

#serverPauseOnConnect

serverPauseOnConnect :: Option ServerOptions Boolean

When true, pauses the Socket on incomming connections. Defaults to false.

Modules