-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | network-simple for resolved addresses
--
@package network-simple-sockaddr
@version 0.2
-- | This is the same API as network-simple with the difference of
-- working on SockAddr instead of HostNames.
--
-- For a more detailed explanation check
-- Network.Simple.TCP
module Network.Simple.SockAddr
-- | Connect to a server and use the connection.
--
-- The connection socket is closed when done or in case of exceptions.
connect :: (MonadIO m, MonadMask m) => SockAddr -> (Socket -> m r) -> m r
-- | Like connect but fork the connection in a different thread.
connectFork :: MonadIO m => SockAddr -> (Socket -> IO ()) -> m ThreadId
-- | Start a server that accepts incoming connections and handles them
-- concurrently in different threads.
--
-- Any acquired network resources are properly closed and discarded when
-- done or in case of exceptions.
serve :: (MonadIO m, MonadMask m) => SockAddr -> (SockAddr -> Socket -> IO ()) -> m ()
-- | Bind a listening socket and use it.
--
-- The listening socket is closed when done or in case of exceptions.
listen :: (MonadIO m, MonadMask m) => SockAddr -> (Socket -> m r) -> m r
-- | Obtain a Socket bound to the given SockAddr.
--
-- The obtained Socket should be closed manually using
-- close when it's not needed anymore.
--
-- Prefer to use listen if you will be listening on this socket
-- and using it within a limited scope, and would like it to be closed
-- immediately after its usage or in case of exceptions.
bind :: (MonadIO m, MonadMask m) => SockAddr -> m Socket
-- | Accept a single incoming connection and use it in a different thread.
--
-- The connection socket is closed when done or in case of exceptions.
acceptFork :: (MonadIO m, MonadCatch m) => Socket -> (SockAddr -> Socket -> IO ()) -> m ThreadId
-- | Writes the given bytes to the socket.
send :: MonadIO m => Socket -> ByteString -> m ()
-- | Read up to a limited number of bytes from a socket.
recv :: MonadIO m => Socket -> Int -> m ByteString
-- | Close the Socket and unlinks the SockAddr for Unix
-- sockets.
close :: MonadIO m => SockAddr -> Socket -> m ()
data Socket :: *
data SockAddr :: *