Module

Node.Datagram

Package
purescript-node-datagram
Repository
brandonhamilton/purescript-node-datagram

This module defines low-level bindings to the Node dgram module.

#Socket Source

data Socket :: Type

The type of a Datagram socket object

#DATAGRAM Source

data DATAGRAM :: Effect

The effect associated with using the Datagram module.

#SocketType Source

data SocketType

Type of Datagram socket

Constructors

#SocketInfo Source

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

Socket address information

#createSocket Source

createSocket :: forall eff. SocketType -> Maybe Boolean -> Eff (dgram :: DATAGRAM | eff) Socket

Creates a Socket data structure

#bindSocket Source

bindSocket :: forall eff. Socket -> Maybe Int -> Maybe String -> Eff (dgram :: DATAGRAM | eff) Unit

Listen for datagram messages. A bound datagram socket keeps the Node.js process running to receive datagram messages

#close Source

close :: forall eff. Socket -> Eff (dgram :: DATAGRAM | eff) Unit

Close the underlying socket and stop listening for data on it

#onMessage Source

onMessage :: forall eff. Socket -> (Buffer -> SocketInfo -> Eff eff Unit) -> Eff eff Unit

Function that will be called when a new datagram is available on a socket

#onListening Source

onListening :: forall eff. Socket -> Eff eff Unit -> Eff eff Unit

Function that will be called whenever a socket begins listening for datagram messages

#onClose Source

onClose :: forall eff. Socket -> Eff eff Unit -> Eff eff Unit

Function that will be called after a socket is closed with close

#onError Source

onError :: forall eff. Socket -> (Error -> Eff eff Unit) -> Eff eff Unit

Function that will be called whenever any error occurs

#send Source

send :: forall eff. Socket -> Buffer -> Maybe Int -> Maybe Int -> Int -> String -> Maybe (Eff eff Unit) -> Eff eff Unit

Broadcasts a datagram on the socket

#sendString Source

sendString :: forall eff. Socket -> String -> Int -> String -> Maybe (Eff eff Unit) -> Eff eff Unit

Broadcasts a datagram on the socket

#address Source

address :: forall eff. Socket -> Eff (dgram :: DATAGRAM | eff) SocketInfo

Return the address information for a socket

#setBroadcast Source

setBroadcast :: forall eff. Socket -> Boolean -> Eff (dgram :: DATAGRAM | eff) Unit

Sets or clears the SO_BROADCAST socket option

#setMulticastLoopback Source

setMulticastLoopback :: forall eff. Socket -> Boolean -> Eff (dgram :: DATAGRAM | eff) Unit

Sets or clears the IP_MULTICAST_LOOP socket option

#setTTL Source

setTTL :: forall eff. Socket -> Int -> Eff (dgram :: DATAGRAM | eff) Unit

Sets the IP_TTL socket option

#setMulticastTTL Source

setMulticastTTL :: forall eff. Socket -> Int -> Eff (dgram :: DATAGRAM | eff) Unit

Sets the IP_MULTICAST_TTL socket option

#addMembership Source

addMembership :: forall eff. Socket -> String -> Maybe String -> Eff (dgram :: DATAGRAM | eff) Unit

Tell the kernel to join a multicast group

#dropMembership Source

dropMembership :: forall eff. Socket -> String -> Maybe String -> Eff (dgram :: DATAGRAM | eff) Unit

Instruct the kernel to leave a multicast group

#unref Source

unref :: forall eff. Socket -> Eff (dgram :: DATAGRAM | eff) Socket

Exclude the socket from the reference counting that keeps the Node.js process active, allowing the process to exit even if the socket is still listening

#ref Source

ref :: forall eff. Socket -> Eff (dgram :: DATAGRAM | eff) Socket

Add the socket back to the reference counting and restore the default behavior

Modules
Node.Datagram