-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | A binding to the POSIX sockets interface -- -- This package provides access to the system's socket interface with -- POSIX semantics. -- -- The library is designed to be threadsafe and establishes a thin layer -- on top of the underlying ccalls to help with the development of -- concurrent applications. It integrates with GHC's event management -- mechanism (which itself uses epoll or libev or similar) and makes all -- functions have blocking semantics without actually blocking the -- runtime system. @package socket @version 0.1.0.0 module System.Socket.Protocol class Protocol p protocolNumber :: Protocol p => p -> CInt instance System.Socket.Protocol.Protocol () module System.Socket.Protocol.UDP data UDP instance System.Socket.Protocol.Protocol System.Socket.Protocol.UDP.UDP module System.Socket.Protocol.TCP data TCP instance System.Socket.Protocol.Protocol System.Socket.Protocol.TCP.TCP module System.Socket.Protocol.SCTP data SCTP instance System.Socket.Protocol.Protocol System.Socket.Protocol.SCTP.SCTP module System.Socket.Type class Type t typeNumber :: Type t => t -> CInt module System.Socket.Type.STREAM data STREAM instance System.Socket.Type.Type System.Socket.Type.STREAM.STREAM module System.Socket.Type.DGRAM data DGRAM instance System.Socket.Type.Type System.Socket.Type.DGRAM.DGRAM module System.Socket.Type.SEQPACKET data SEQPACKET instance System.Socket.Type.Type System.Socket.Type.SEQPACKET.SEQPACKET module System.Socket.Address class (Storable f) => Address f addressFamilyNumber :: Address f => f -> CInt module System.Socket.Address.SockAddrUn data SockAddrUn SockAddrUn :: ByteString -> SockAddrUn [sunPath] :: SockAddrUn -> ByteString instance GHC.Show.Show System.Socket.Address.SockAddrUn.SockAddrUn instance GHC.Classes.Ord System.Socket.Address.SockAddrUn.SockAddrUn instance GHC.Classes.Eq System.Socket.Address.SockAddrUn.SockAddrUn instance System.Socket.Address.Address System.Socket.Address.SockAddrUn.SockAddrUn instance Foreign.Storable.Storable System.Socket.Address.SockAddrUn.SockAddrUn module System.Socket.Address.SockAddrIn data SockAddrIn SockAddrIn :: Word16 -> ByteString -> SockAddrIn [sinPort] :: SockAddrIn -> Word16 [sinAddr] :: SockAddrIn -> ByteString instance GHC.Show.Show System.Socket.Address.SockAddrIn.SockAddrIn instance GHC.Classes.Ord System.Socket.Address.SockAddrIn.SockAddrIn instance GHC.Classes.Eq System.Socket.Address.SockAddrIn.SockAddrIn instance System.Socket.Address.Address System.Socket.Address.SockAddrIn.SockAddrIn instance Foreign.Storable.Storable System.Socket.Address.SockAddrIn.SockAddrIn module System.Socket.Address.SockAddrIn6 data SockAddrIn6 SockAddrIn6 :: Word16 -> Word32 -> ByteString -> Word32 -> SockAddrIn6 [sin6Port] :: SockAddrIn6 -> Word16 [sin6Flowinfo] :: SockAddrIn6 -> Word32 [sin6Addr] :: SockAddrIn6 -> ByteString [sin6ScopeId] :: SockAddrIn6 -> Word32 instance GHC.Show.Show System.Socket.Address.SockAddrIn6.SockAddrIn6 instance GHC.Classes.Ord System.Socket.Address.SockAddrIn6.SockAddrIn6 instance GHC.Classes.Eq System.Socket.Address.SockAddrIn6.SockAddrIn6 instance System.Socket.Address.Address System.Socket.Address.SockAddrIn6.SockAddrIn6 instance Foreign.Storable.Storable System.Socket.Address.SockAddrIn6.SockAddrIn6 module System.Socket.Internal.FFI newtype MsgFlags MsgFlags :: CInt -> MsgFlags c_socket :: CInt -> CInt -> CInt -> IO Fd c_close :: Fd -> IO CInt c_bind :: Fd -> Ptr a -> CInt -> IO CInt c_connect :: Fd -> Ptr a -> CSize -> IO CInt c_accept :: Fd -> Ptr a -> Ptr CInt -> IO Fd c_listen :: Fd -> CInt -> IO CInt c_send :: Fd -> Ptr a -> CSize -> MsgFlags -> IO CInt c_sendto :: Fd -> Ptr a -> CSize -> MsgFlags -> Ptr b -> CInt -> IO CInt c_recv :: Fd -> Ptr a -> CSize -> MsgFlags -> IO CInt c_recvfrom :: Fd -> Ptr a -> CSize -> MsgFlags -> Ptr b -> Ptr CInt -> IO CInt c_getsockopt :: Fd -> CInt -> CInt -> Ptr a -> Ptr Int -> IO CInt c_setnonblocking :: Fd -> IO CInt instance GHC.Base.Monoid System.Socket.Internal.FFI.MsgFlags module System.Socket.Internal.Socket -- | A generic socket type. Also see socket for details. -- -- The socket is just an MVar-wrapped file descriptor. It is -- exposed in order to make this library easily extensible, but it is -- usually not necessary nor advised to work directly on the file -- descriptor. If you do, the following rules must be obeyed: -- -- newtype Socket d t p Socket :: (MVar Fd) -> Socket d t p newtype SocketException SocketException :: Errno -> SocketException newtype MsgFlags MsgFlags :: CInt -> MsgFlags msgEOR :: MsgFlags msgOOB :: MsgFlags msgNOSIGNAL :: MsgFlags class GetSockOpt o getSockOpt :: GetSockOpt o => Socket f t p -> IO o class SetSockOpt o setSockOpt :: SetSockOpt o => Socket f t p -> o -> IO () data SO_ACCEPTCONN SO_ACCEPTCONN :: Bool -> SO_ACCEPTCONN instance GHC.Exception.Exception System.Socket.Internal.Socket.SocketException instance GHC.Show.Show System.Socket.Internal.Socket.SocketException instance System.Socket.Internal.Socket.GetSockOpt System.Socket.Internal.Socket.SO_ACCEPTCONN module System.Socket.Internal.Event threadWaitReadMVar :: MVar Fd -> IO () threadWaitWriteMVar :: MVar Fd -> IO () threadWaitWrite' :: Fd -> IO (IO ()) threadWaitRead' :: Fd -> IO (IO ()) module System.Socket.Unsafe unsafeSend :: (Address a, Type t, Protocol p) => Socket a t p -> Ptr b -> CSize -> MsgFlags -> IO CInt unsafeSendTo :: (Address a, Type t, Protocol p) => Socket a t p -> Ptr b -> CSize -> MsgFlags -> Ptr a -> CInt -> IO CInt unsafeRecv :: (Address a, Type t, Protocol p) => Socket a t p -> Ptr b -> CSize -> MsgFlags -> IO CInt unsafeRecvFrom :: (Address a, Type t, Protocol p) => Socket a t p -> Ptr b -> CSize -> MsgFlags -> Ptr a -> Ptr CInt -> IO CInt -- |
--   {-# LANGUAGE OverloadedStrings #-}
--   module Main where
--   
--   import System.Socket
--   import Data.ByteString
--   import Control.Monad
--   import Control.Concurrent
--   
--   main :: IO ()
--   main = do
--     s <- socket :: IO (Socket SockAddrIn STREAM TCP)
--     bind s (SockAddrIn 8080 (pack [127,0,0,1]))
--     listen s 5
--     forever $ do
--       (peer,addr) <- accept s
--       forkIO $ do
--         send peer "Hello world!"
--         close peer
--   
module System.Socket -- | Creates a new socket. -- -- Whereas the underlying POSIX socket function takes 3 parameters, this -- library encodes this information in the type variables. This rules out -- several kinds of errors and escpecially simplifies the handling of -- addresses (by using associated type families). Examples: -- --
--   -- create a IPv4-UDP-datagram socket
--   sock <- socket :: IO (Socket SockAddrIn DGRAM UDP)
--   -- create a IPv6-TCP-streaming socket
--   sock6 <- socket :: IO (Socket SockAddrIn6 STREAM TCP)
--   
-- -- -- -- socket :: (Address a, Type t, Protocol p) => IO (Socket a t p) -- | Bind a socket to an address. -- -- -- -- -- -- -- -- bind :: (Address a, Type t, Protocol p) => Socket a t p -> a -> IO () -- | Accept connections on a connection-mode socket. -- -- -- -- listen :: (Address a, Type t, Protocol p) => Socket a t p -> Int -> IO () -- | Accept a new connection. -- -- -- -- accept :: (Address a, Type t, Protocol p) => Socket a t p -> IO (Socket a t p, a) -- | Connects to an remote address. -- -- -- -- -- -- -- -- connect :: (Address a, Type t, Protocol p) => Socket a t p -> a -> IO () -- | Send a message on a connected socket. -- -- -- -- -- -- -- -- send :: (Address a, Type t, Protocol p) => Socket a t p -> ByteString -> MsgFlags -> IO Int -- | Send a message on a socket with a specific destination address. -- -- -- -- -- -- -- -- sendTo :: (Address a, Type t, Protocol p) => Socket a t p -> ByteString -> MsgFlags -> a -> IO Int -- | Receive a message on a connected socket. -- -- -- -- -- -- -- -- recv :: (Address a, Type t, Protocol p) => Socket a t p -> Int -> MsgFlags -> IO ByteString -- | Receive a message on a socket and additionally yield the peer address. -- -- -- -- -- -- -- -- recvFrom :: (Address a, Type t, Protocol p) => Socket a t p -> Int -> MsgFlags -> IO (ByteString, a) -- | Closes a socket. -- -- -- -- -- -- -- -- close :: (Address a, Type t, Protocol p) => Socket a t p -> IO () -- | A generic socket type. Also see socket for details. -- -- The socket is just an MVar-wrapped file descriptor. It is -- exposed in order to make this library easily extensible, but it is -- usually not necessary nor advised to work directly on the file -- descriptor. If you do, the following rules must be obeyed: -- -- data Socket d t p class (Storable f) => Address f addressFamilyNumber :: Address f => f -> CInt data SockAddrUn SockAddrUn :: ByteString -> SockAddrUn [sunPath] :: SockAddrUn -> ByteString data SockAddrIn SockAddrIn :: Word16 -> ByteString -> SockAddrIn [sinPort] :: SockAddrIn -> Word16 [sinAddr] :: SockAddrIn -> ByteString data SockAddrIn6 SockAddrIn6 :: Word16 -> Word32 -> ByteString -> Word32 -> SockAddrIn6 [sin6Port] :: SockAddrIn6 -> Word16 [sin6Flowinfo] :: SockAddrIn6 -> Word32 [sin6Addr] :: SockAddrIn6 -> ByteString [sin6ScopeId] :: SockAddrIn6 -> Word32 class Type t typeNumber :: Type t => t -> CInt data STREAM data DGRAM data SEQPACKET class Protocol p protocolNumber :: Protocol p => p -> CInt data UDP data TCP data SCTP data MsgFlags msgEOR :: MsgFlags msgOOB :: MsgFlags msgNOSIGNAL :: MsgFlags class GetSockOpt o getSockOpt :: GetSockOpt o => Socket f t p -> IO o class SetSockOpt o setSockOpt :: SetSockOpt o => Socket f t p -> o -> IO () data SO_ACCEPTCONN SO_ACCEPTCONN :: Bool -> SO_ACCEPTCONN newtype SocketException SocketException :: Errno -> SocketException