sockets-0.4.0.0: High-level network sockets

Safe HaskellNone
LanguageHaskell2010

Socket.Datagram.IPv4.Unconnected

Contents

Description

Internet datagram sockets without a fixed destination.

Synopsis

Types

newtype Socket (a :: Connectedness) (b :: Family) #

Constructors

Socket Fd 
Instances
Eq (Socket a b) 
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) 
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) 
Instance details

Defined in Socket.Datagram

Methods

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

show :: Socket a b -> String #

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

data Peer #

Constructors

Peer 

Fields

Instances
Eq Peer 
Instance details

Defined in Socket.IPv4

Methods

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

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

Show Peer 
Instance details

Defined in Socket.IPv4

Methods

showsPrec :: Int -> Peer -> ShowS #

show :: Peer -> String #

showList :: [Peer] -> ShowS #

data Message #

Constructors

Message 

Fields

Instances
Eq Message 
Instance details

Defined in Socket.IPv4

Methods

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

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

Show Message 
Instance details

Defined in Socket.IPv4

Establish

withSocket Source #

Arguments

:: Peer

Address and port to use

-> (Socket Unconnected (Internet V4) -> Word16 -> IO a)

Callback providing the socket and the chosen port

-> IO (Either SocketException a) 

Open a socket and run the supplied callback on it. This closes the socket when the callback finishes or when an exception is thrown. Do not return the socket from the callback. This leads to undefined behavior. If the address 0.0.0.0 is used, the socket receives on all network interfaces. If the port 0 is used, an unused port is chosen by the operating system. The callback provides the chosen port (or if the user specified a non-zero port, the chosen port will be that value).

Exceptions