Module

Node.Net.Server

Package
purescript-node-net
Repository
purescript-node/purescript-node-net

#Address Source

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

#ListenOptions Source

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 Source

data Server :: Type

An ICP or TCP server.

#ServerOptions Source

data ServerOptions

Options to configure the basics of a Server.

#address Source

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 Source

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 Source

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 Source

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

Returns the number of concurrent connections to the Server.

#listen Source

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 Source

listenBacklog :: Option ListenOptions Int

Maximum number of pending connections. Defaults to 511.

#listenExclusive Source

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 Source

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 Source

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 Source

listenIpv6Only :: Option ListenOptions Boolean

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

#listenPath Source

listenPath :: Option ListenOptions String

The path to configure ICP Servers.

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

#listenPort Source

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 Source

listenReadableAll :: Option ListenOptions Boolean

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

#listenTCP Source

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 Source

listenWritableAll :: Option ListenOptions Boolean

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

#listening Source

listening :: Server -> Effect Boolean

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

#onClose Source

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 Source

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 Source

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 Source

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 Source

serverAllowHalfOpen :: Option ServerOptions Boolean

Allows half open TCP connections. Defaults to false.

#serverPauseOnConnect Source

serverPauseOnConnect :: Option ServerOptions Boolean

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