Safe Haskell | None |
---|---|
Language | Haskell98 |
- type HostName = String
- data Address
- withStream :: Address -> (Handle -> IO a) -> IO a
- connectStream :: Address -> IO Handle
- connectDgram :: Address -> IO Socket
- withDgram :: Address -> (Socket -> IO a) -> IO a
- class StringLike string
- recv :: StringLike string => Socket -> Int -> IO string
- send :: StringLike string => Socket -> string -> IO ()
- closeSocket :: Socket -> IO ()
- data ServerSpec = ServerSpec {}
- serverSpec :: ServerSpec
- data Threading
- data Reverse
- streamServer :: ServerSpec -> (Handle -> Address -> IO ()) -> IO [ThreadId]
- dgramServer :: StringLike packet => ServerSpec -> (packet -> Address -> IO [packet]) -> IO [ThreadId]
- sleepForever :: IO ()
- getCurrentHost :: IO HostName
- data Socket
- data NetworkException
Address
Stream clients
withStream :: Address -> (Handle -> IO a) -> IO a Source
Open a stream (tcp) socket for the given block and close it afterwards.
connectStream :: Address -> IO Handle Source
Open a stream (tcp) socket.
Datagram clients
connectDgram :: Address -> IO Socket Source
Open a datagram (udp) socket.
withDgram :: Address -> (Socket -> IO a) -> IO a Source
Open a datagram (udp) socket for the given block and close it afterwards.
class StringLike string Source
toBS, fromBS
StringLike String | |
StringLike ByteString | |
StringLike ByteString |
recv :: StringLike string => Socket -> Int -> IO string Source
Receive one chunk with given maximum size
send :: StringLike string => Socket -> string -> IO () Source
Send the string as one chunk
closeSocket :: Socket -> IO () Source
Close the socket specified.
Servers
data ServerSpec Source
ServerSpec | |
|
serverSpec :: ServerSpec Source
Default server specification
ReverseNumeric | Use numeric addresses for peers. |
ReverseName | Resolve reverse names if possible for peers. |
streamServer :: ServerSpec -> (Handle -> Address -> IO ()) -> IO [ThreadId] Source
Run a stream (tcp) server. The function does not block, use sleepForever if that is desired.
:: StringLike packet | |
=> ServerSpec | Server specification |
-> (packet -> Address -> IO [packet]) | The server function is given a received packet and the Address of the peer. It returns a list of reply packets to send to that peer. Note that the list elements are invidual packets, not concatenated together. |
-> IO [ThreadId] | ThreadIds of the server listener processes. |
Run a datagram (udp) server. The function does not block, use sleepForever if that is desired.
sleepForever :: IO () Source
Sleep forever. Useful after a server.
Other
getCurrentHost :: IO HostName Source
Get the current hostname.
data NetworkException Source
Exceptions occuring in network-fancy.