sockets-0.4.0.0: High-level network sockets

Safe HaskellNone
LanguageHaskell2010

Socket.IPv4

Synopsis

Documentation

data Peer Source #

An peer for an IPv4 socket, connection, or listener. Everything is in host byte order, and the user is not responsible for performing any conversions.

Constructors

Peer 

Fields

Instances
Eq Peer Source # 
Instance details

Defined in Socket.IPv4

Methods

(==) :: Peer -> Peer -> Bool #

(/=) :: Peer -> Peer -> Bool #

Show Peer Source # 
Instance details

Defined in Socket.IPv4

Methods

showsPrec :: Int -> Peer -> ShowS #

show :: Peer -> String #

showList :: [Peer] -> ShowS #

data Message Source #

A message received from a peer.

Constructors

Message 

Fields

Instances
Eq Message Source # 
Instance details

Defined in Socket.IPv4

Methods

(==) :: Message -> Message -> Bool #

(/=) :: Message -> Message -> Bool #

Show Message Source # 
Instance details

Defined in Socket.IPv4

data IPv4Slab Source #

A slab of memory for bulk datagram ingest (via recvmmsg). This approach cuts down on allocations. Slabs are not safe for concurrent access. Do not share a slab across multiple threads.

Constructors

IPv4Slab 

Fields

data SocketException :: Type where Source #

Recoverable exceptions that happen when establishing an internet-domain stream listener or datagram socket.

Discussion

Expand

The recoverable exceptions that we encounter with stream sockets (established with socket-bind-listen) and datagram sockets (established with socket-bind) are the exact same exceptions. Consequently, we reuse the same type in both case. It is a little unfortunate since the name ListenException would be more appropriate for stream sockets. But the code reuse is worth the naming quibble.

Constructors

SocketPermissionDenied :: SocketException

The address is protected, and the user is not the superuser. This most commonly happens when trying to bind to a port below 1024. On Linux, When it is necessary to bind to such a port on Linux, consider using the CAP_NET_BIND_SERVICE capability instead of running the process as root. (EACCES)

SocketAddressInUse :: SocketException

The given address is already in use. (EADDRINUSE with specified port)

SocketEphemeralPortsExhausted :: SocketException

The port number was specified as zero, but upon attempting to bind to an ephemeral port, it was determined that all port numbers numbers in the ephemeral port range are currently in use. (EADDRINUSE with unspecified port)

SocketFileDescriptorLimit :: SocketException

A limit on the number of open file descriptors has been reached. This could be the per-process limit or the system limit. (EMFILE and ENFILE)

freezeIPv4Slab Source #

Arguments

:: IPv4Slab

The slab

-> Int

Number of messages in the slab.

-> IO (SmallArray Message) 

Freeze the specified number of messages in-place and return them (along with their origin peers). Replaces all of the frozen messages with tombstones so that new buffers can be allocated before the next reception. End users should not need this function.

newIPv4Slab Source #

Arguments

:: Int

maximum datagrams

-> Int

maximum size of individual datagram

-> IO IPv4Slab 

Allocate a slab that is used to receive multiple datagrams at the same time, additionally storing the IPv4 addresses of the peers.