sockets-0.4.0.0: High-level network sockets

Safe HaskellNone
LanguageHaskell2010

Socket.Datagram

Synopsis

Documentation

newtype Socket :: Connectedness -> Family -> Type where Source #

A datagram socket. The Connectedness refers to whether or not POSIX connect has been applied to the socket. A connected socket socket uses POSIX send/recv to communicate with a single peer. An unconnected socket uses POSIX sendto/recvfrom to communicate with many peers. The Family refers to whether this socket uses IPv4, IPv6, or Unix (local).

Constructors

Socket :: Fd -> Socket c a 
Instances
Eq (Socket a b) Source # 
Instance details

Defined in Socket.Datagram

Methods

(==) :: Socket a b -> Socket a b -> Bool #

(/=) :: Socket a b -> Socket a b -> Bool #

Ord (Socket a b) Source # 
Instance details

Defined in Socket.Datagram

Methods

compare :: Socket a b -> Socket a b -> Ordering #

(<) :: Socket a b -> Socket a b -> Bool #

(<=) :: Socket a b -> Socket a b -> Bool #

(>) :: Socket a b -> Socket a b -> Bool #

(>=) :: Socket a b -> Socket a b -> Bool #

max :: Socket a b -> Socket a b -> Socket a b #

min :: Socket a b -> Socket a b -> Socket a b #

Show (Socket a b) Source # 
Instance details

Defined in Socket.Datagram

Methods

showsPrec :: Int -> Socket a b -> ShowS #

show :: Socket a b -> String #

showList :: [Socket a b] -> ShowS #

data SendException :: Interruptibility -> Type where Source #

Constructors

SendTruncated :: !Int -> SendException i

The datagram did not fit in the buffer. The field is the number of bytes that were successfully copied into the send buffer. The datagram does still get sent when this happens.

SendBroadcasted :: SendException i

Attempted to send to a broadcast address.

SendInterrupted :: SendException Interruptible

STM-style interrupt (much safer than C-style interrupt)

data ReceiveException :: Interruptibility -> Type where Source #

Constructors

ReceiveTruncated :: !Int -> ReceiveException i

The datagram did not fit in the buffer. The field is the original size of the datagram that was truncated. If this happens, the process probably needs to start using a larger receive buffer.

ReceiveInterrupted :: ReceiveException Interruptible

STM-style interrupt (much safer than C-style interrupt)

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)