network-transport-0.5.2: Network abstraction layer

Safe HaskellNone
LanguageHaskell98

Network.Transport

Contents

Description

Network Transport

Synopsis

Types

data Transport Source #

To create a network abstraction layer, use one of the Network.Transport.* packages.

Constructors

Transport 

Fields

data EndPoint Source #

Network endpoint.

Constructors

EndPoint 

Fields

data Connection Source #

Lightweight connection to an endpoint.

Constructors

Connection 

Fields

data Event Source #

Event on an endpoint.

Constructors

Received !ConnectionId [ByteString]

Received a message

ConnectionClosed !ConnectionId

Connection closed

ConnectionOpened !ConnectionId Reliability EndPointAddress

Connection opened

ConnectionIds need not be allocated contiguously.

ReceivedMulticast MulticastAddress [ByteString]

Received multicast

EndPointClosed

The endpoint got closed (manually, by a call to closeEndPoint or closeTransport)

ErrorEvent (TransportError EventErrorCode)

An error occurred

Instances

Eq Event Source # 

Methods

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

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

Show Event Source # 

Methods

showsPrec :: Int -> Event -> ShowS #

show :: Event -> String #

showList :: [Event] -> ShowS #

Generic Event Source # 

Associated Types

type Rep Event :: * -> * #

Methods

from :: Event -> Rep Event x #

to :: Rep Event x -> Event #

Binary Event Source # 

Methods

put :: Event -> Put #

get :: Get Event #

putList :: [Event] -> Put #

type Rep Event Source # 

type ConnectionId = Word64 Source #

Connection data ConnectHintsIDs enable receivers to distinguish one connection from another.

data Reliability Source #

Reliability guarantees of a connection.

Instances

Eq Reliability Source # 
Show Reliability Source # 
Generic Reliability Source # 

Associated Types

type Rep Reliability :: * -> * #

Binary Reliability Source # 
type Rep Reliability Source # 
type Rep Reliability = D1 (MetaData "Reliability" "Network.Transport" "network-transport-0.5.2-3YhrKUcA726KShFG4aI2N3" False) ((:+:) (C1 (MetaCons "ReliableOrdered" PrefixI False) U1) ((:+:) (C1 (MetaCons "ReliableUnordered" PrefixI False) U1) (C1 (MetaCons "Unreliable" PrefixI False) U1)))

data MulticastGroup Source #

Multicast group.

Constructors

MulticastGroup 

Fields

newtype EndPointAddress Source #

EndPointAddress of an endpoint.

Instances

Eq EndPointAddress Source # 
Data EndPointAddress Source # 

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> EndPointAddress -> c EndPointAddress #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c EndPointAddress #

toConstr :: EndPointAddress -> Constr #

dataTypeOf :: EndPointAddress -> DataType #

dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c EndPointAddress) #

dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c EndPointAddress) #

gmapT :: (forall b. Data b => b -> b) -> EndPointAddress -> EndPointAddress #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> EndPointAddress -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> EndPointAddress -> r #

gmapQ :: (forall d. Data d => d -> u) -> EndPointAddress -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> EndPointAddress -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> EndPointAddress -> m EndPointAddress #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> EndPointAddress -> m EndPointAddress #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> EndPointAddress -> m EndPointAddress #

Ord EndPointAddress Source # 
Show EndPointAddress Source # 
Binary EndPointAddress Source # 
NFData EndPointAddress Source # 

Methods

rnf :: EndPointAddress -> () #

Hashable EndPointAddress Source # 

newtype MulticastAddress Source #

EndPointAddress of a multicast group.

Hints

data ConnectHints Source #

Hints used by connect

Constructors

ConnectHints 

defaultConnectHints :: ConnectHints Source #

Default hints for connecting

Error codes

data TransportError error Source #

Errors returned by Network.Transport API functions consist of an error code and a human readable description of the problem

Constructors

TransportError error String 

Instances

Eq error => Eq (TransportError error) Source #

When comparing errors we ignore the human-readable strings

Methods

(==) :: TransportError error -> TransportError error -> Bool #

(/=) :: TransportError error -> TransportError error -> Bool #

Show error => Show (TransportError error) Source # 

Methods

showsPrec :: Int -> TransportError error -> ShowS #

show :: TransportError error -> String #

showList :: [TransportError error] -> ShowS #

Generic (TransportError error) Source # 

Associated Types

type Rep (TransportError error) :: * -> * #

Methods

from :: TransportError error -> Rep (TransportError error) x #

to :: Rep (TransportError error) x -> TransportError error #

(Typeable * err, Show err) => Exception (TransportError err) Source #

Although the functions in the transport API never throw TransportErrors (but return them explicitly), application code may want to turn these into exceptions.

Binary error => Binary (TransportError error) Source # 

Methods

put :: TransportError error -> Put #

get :: Get (TransportError error) #

putList :: [TransportError error] -> Put #

type Rep (TransportError error) Source # 
type Rep (TransportError error) = D1 (MetaData "TransportError" "Network.Transport" "network-transport-0.5.2-3YhrKUcA726KShFG4aI2N3" False) (C1 (MetaCons "TransportError" PrefixI False) ((:*:) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 error)) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 String))))

data ConnectErrorCode Source #

Connection failure

Constructors

ConnectNotFound

Could not resolve the address

ConnectInsufficientResources

Insufficient resources (for instance, no more sockets available)

ConnectTimeout

Timeout

ConnectFailed

Failed for other reasons (including syntax error)

data SendErrorCode Source #

Failure during sending a message

Constructors

SendClosed

Connection was closed

SendFailed

Send failed for some other reason

data EventErrorCode Source #

Error codes used when reporting errors to endpoints (through receive)

Constructors

EventEndPointFailed

Failure of the entire endpoint

EventTransportFailed

Transport-wide fatal error

EventConnectionLost EndPointAddress

We lost connection to another endpoint

Although Network.Transport provides multiple independent lightweight connections between endpoints, those connections cannot fail independently: once one connection has failed, all connections, in both directions, must now be considered to have failed; they fail as a "bundle" of connections, with only a single "bundle" of connections per endpoint at any point in time.

That is, suppose there are multiple connections in either direction between endpoints A and B, and A receives a notification that it has lost contact with B. Then A must not be able to send any further messages to B on existing connections.

Although B may not realize immediately that its connection to A has been broken, messages sent by B on existing connections should not be delivered, and B must eventually get an EventConnectionLost message, too.

Moreover, this event must be posted before A has successfully reconnected (in other words, if B notices a reconnection attempt from A, it must post the EventConnectionLost before acknowledging the connection from A) so that B will not receive events about new connections or incoming messages from A without realizing that it got disconnected.

If B attempts to establish another connection to A before it realized that it got disconnected from A then it's okay for this connection attempt to fail, and the EventConnectionLost to be posted at that point, or for the EventConnectionLost to be posted and for the new connection to be considered the first connection of the "new bundle".