Safe Haskell | None |
---|---|
Language | Haskell98 |
Network Transport
Synopsis
- data Transport = Transport {}
- data EndPoint = EndPoint {
- receive :: IO Event
- address :: EndPointAddress
- connect :: EndPointAddress -> Reliability -> ConnectHints -> IO (Either (TransportError ConnectErrorCode) Connection)
- newMulticastGroup :: IO (Either (TransportError NewMulticastGroupErrorCode) MulticastGroup)
- resolveMulticastGroup :: MulticastAddress -> IO (Either (TransportError ResolveMulticastGroupErrorCode) MulticastGroup)
- closeEndPoint :: IO ()
- data Connection = Connection {
- send :: [ByteString] -> IO (Either (TransportError SendErrorCode) ())
- close :: IO ()
- data Event
- type ConnectionId = Word64
- data Reliability
- data MulticastGroup = MulticastGroup {
- multicastAddress :: MulticastAddress
- deleteMulticastGroup :: IO ()
- maxMsgSize :: Maybe Int
- multicastSend :: [ByteString] -> IO ()
- multicastSubscribe :: IO ()
- multicastUnsubscribe :: IO ()
- multicastClose :: IO ()
- newtype EndPointAddress = EndPointAddress {}
- newtype MulticastAddress = MulticastAddress {}
- data ConnectHints = ConnectHints {}
- defaultConnectHints :: ConnectHints
- data TransportError error = TransportError error String
- data NewEndPointErrorCode
- data ConnectErrorCode
- data NewMulticastGroupErrorCode
- data ResolveMulticastGroupErrorCode
- data SendErrorCode
- data EventErrorCode
Types
To create a network abstraction layer, use one of the
Network.Transport.*
packages.
Transport | |
|
Network endpoint.
EndPoint | |
|
data Connection Source #
Lightweight connection to an endpoint.
Connection | |
|
Event on an endpoint.
Received !ConnectionId [ByteString] | Received a message |
ConnectionClosed !ConnectionId | Connection closed |
ConnectionOpened !ConnectionId Reliability EndPointAddress | Connection opened
|
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
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 # | |
Defined in Network.Transport (==) :: Reliability -> Reliability -> Bool # (/=) :: Reliability -> Reliability -> Bool # | |
Show Reliability Source # | |
Defined in Network.Transport showsPrec :: Int -> Reliability -> ShowS # show :: Reliability -> String # showList :: [Reliability] -> ShowS # | |
Generic Reliability Source # | |
Defined in Network.Transport type Rep Reliability :: Type -> Type # from :: Reliability -> Rep Reliability x # to :: Rep Reliability x -> Reliability # | |
Binary Reliability Source # | |
Defined in Network.Transport | |
type Rep Reliability Source # | |
Defined in Network.Transport type Rep Reliability = D1 (MetaData "Reliability" "Network.Transport" "network-transport-0.5.4-HGsdCuWTMfG5PmPV05LOOP" False) (C1 (MetaCons "ReliableOrdered" PrefixI False) (U1 :: Type -> Type) :+: (C1 (MetaCons "ReliableUnordered" PrefixI False) (U1 :: Type -> Type) :+: C1 (MetaCons "Unreliable" PrefixI False) (U1 :: Type -> Type))) |
data MulticastGroup Source #
Multicast group.
MulticastGroup | |
|
newtype EndPointAddress Source #
EndPointAddress of an endpoint.
Instances
newtype MulticastAddress Source #
EndPointAddress of a multicast group.
Instances
Hints
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
TransportError error String |
Instances
data NewEndPointErrorCode Source #
Errors during the creation of an endpoint
NewEndPointInsufficientResources | Not enough resources |
NewEndPointFailed | Failed for some other reason |
Instances
Eq NewEndPointErrorCode Source # | |
Defined in Network.Transport (==) :: NewEndPointErrorCode -> NewEndPointErrorCode -> Bool # (/=) :: NewEndPointErrorCode -> NewEndPointErrorCode -> Bool # | |
Show NewEndPointErrorCode Source # | |
Defined in Network.Transport showsPrec :: Int -> NewEndPointErrorCode -> ShowS # show :: NewEndPointErrorCode -> String # showList :: [NewEndPointErrorCode] -> ShowS # |
data ConnectErrorCode Source #
Connection failure
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) |
Instances
Eq ConnectErrorCode Source # | |
Defined in Network.Transport (==) :: ConnectErrorCode -> ConnectErrorCode -> Bool # (/=) :: ConnectErrorCode -> ConnectErrorCode -> Bool # | |
Show ConnectErrorCode Source # | |
Defined in Network.Transport showsPrec :: Int -> ConnectErrorCode -> ShowS # show :: ConnectErrorCode -> String # showList :: [ConnectErrorCode] -> ShowS # |
data NewMulticastGroupErrorCode Source #
Failure during the creation of a new multicast group
NewMulticastGroupInsufficientResources | Insufficient resources |
NewMulticastGroupFailed | Failed for some other reason |
NewMulticastGroupUnsupported | Not all transport implementations support multicast |
Instances
Eq NewMulticastGroupErrorCode Source # | |
Defined in Network.Transport | |
Show NewMulticastGroupErrorCode Source # | |
Defined in Network.Transport showsPrec :: Int -> NewMulticastGroupErrorCode -> ShowS # show :: NewMulticastGroupErrorCode -> String # showList :: [NewMulticastGroupErrorCode] -> ShowS # |
data ResolveMulticastGroupErrorCode Source #
Failure during the resolution of a multicast group
ResolveMulticastGroupNotFound | Multicast group not found |
ResolveMulticastGroupFailed | Failed for some other reason (including syntax error) |
ResolveMulticastGroupUnsupported | Not all transport implementations support multicast |
Instances
Eq ResolveMulticastGroupErrorCode Source # | |
Show ResolveMulticastGroupErrorCode Source # | |
Defined in Network.Transport |
data SendErrorCode Source #
Failure during sending a message
SendClosed | Connection was closed |
SendFailed | Send failed for some other reason |
Instances
Eq SendErrorCode Source # | |
Defined in Network.Transport (==) :: SendErrorCode -> SendErrorCode -> Bool # (/=) :: SendErrorCode -> SendErrorCode -> Bool # | |
Show SendErrorCode Source # | |
Defined in Network.Transport showsPrec :: Int -> SendErrorCode -> ShowS # show :: SendErrorCode -> String # showList :: [SendErrorCode] -> ShowS # |
data EventErrorCode Source #
Error codes used when reporting errors to endpoints (through receive)
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". |