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

#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 :: SocketType -> Maybe Boolean -> Effect Socket

Creates a Socket data structure

#bindSocket Source

bindSocket :: Socket -> Maybe Int -> Maybe String -> Effect Unit

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

#close Source

close :: Socket -> Effect Unit

Close the underlying socket and stop listening for data on it

#send Source

send :: Socket -> Buffer -> Maybe Int -> Maybe Int -> Int -> String -> Maybe (Effect Unit) -> Effect Unit

Broadcasts a datagram on the socket

#sendString Source

sendString :: Socket -> String -> Int -> String -> Maybe (Effect Unit) -> Effect Unit

Broadcasts a datagram on the socket

#onMessage Source

onMessage :: Socket -> (Buffer -> SocketInfo -> Effect Unit) -> Effect Unit

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

#onListening Source

onListening :: Socket -> Effect Unit -> Effect Unit

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

#onClose Source

onClose :: Socket -> Effect Unit -> Effect Unit

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

#onError Source

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

Function that will be called whenever any error occurs

#address Source

address :: Socket -> Effect SocketInfo

Return the address information for a socket

#setBroadcast Source

setBroadcast :: Socket -> Boolean -> Effect Unit

Sets or clears the SO_BROADCAST socket option

#setMulticastLoopback Source

setMulticastLoopback :: Socket -> Boolean -> Effect Unit

Sets or clears the IP_MULTICAST_LOOP socket option

#setTTL Source

setTTL :: Socket -> Int -> Effect Unit

Sets the IP_TTL socket option

#setMulticastTTL Source

setMulticastTTL :: Socket -> Int -> Effect Unit

Sets the IP_MULTICAST_TTL socket option

#addMembership Source

addMembership :: Socket -> String -> Maybe String -> Effect Unit

Tell the kernel to join a multicast group

#dropMembership Source

dropMembership :: Socket -> String -> Maybe String -> Effect Unit

Instruct the kernel to leave a multicast group

#unref Source

unref :: Socket -> Effect 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 :: Socket -> Effect Socket

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

Modules
Node.Datagram