-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Bindings to the POSIX socket API -- -- This package provides bindings to the POSIX socket API. @package posix-socket @version 0.3 -- | POSIX sockets. module System.Posix.Socket -- | Socket of a particular family. data Socket f -- | Lock the socket and pass the underlying file descriptor to the given -- action. withSocketFd :: MonadBase IO μ => Socket f -> (Fd -> IO α) -> μ α -- | Get the underlying file descriptor. unsafeSocketFd :: MonadBase IO μ => Socket f -> μ Fd -- | Use file descriptor as a socket. unsafeSocketFromFd :: MonadBase IO μ => Fd -> μ (Socket f) -- | Socket family. class SockAddr (SockFamilyAddr f) => SockFamily f where { type family SockFamilyAddr f; } -- | Socket family code. sockFamilyCode :: SockFamily f => Proxy f -> CInt -- | Socket address. class SockAddr a -- | Maximum size of a socket address. sockAddrMaxSize :: SockAddr a => Proxy a -> Int -- | Size of a particular socket address. sockAddrSize :: SockAddr a => a -> Int -- | Read socket address from a memory buffer. peekSockAddr :: SockAddr a => Ptr a -> Int -> IO a -- | Write socket address to a memory buffer. pokeSockAddr :: SockAddr a => Ptr a -> a -> IO () -- | Socket type. newtype SockType SockType :: CInt -> SockType -- | See socket(2). -- | See socket(2). -- | See socket(2). -- | See socket(2). -- | See socket(2). -- | Socket protocol. newtype SockProto SockProto :: CInt -> SockProto -- | Default socket protocol (corresponds to 0). defaultSockProto :: SockProto -- | Socket option. class Storable (SockOptRaw o) => SockOpt o where { type family SockOptValue o; type family SockOptRaw o; type family SockOptReadable o :: Bool; type family SockOptWritable o :: Bool; } -- | Convert to FFI-level value sockOptRaw :: SockOpt o => Proxy o -> SockOptValue o -> SockOptRaw o -- | Convert from FFI-level value sockOptValue :: SockOpt o => Proxy o -> SockOptRaw o -> SockOptValue o -- | Option protocol level sockOptLevel :: SockOpt o => Proxy o -> CInt -- | Option code sockOptCode :: SockOpt o => Proxy o -> CInt data SO_ERROR data SO_KEEPALIVE data SO_REUSEADDR -- | Socket operations. data SockOps NoSockOps :: SockOps RecvSockOps :: SockOps SendSockOps :: SockOps AllSockOps :: SockOps -- | Message flags. newtype MsgFlags MsgFlags :: CInt -> MsgFlags -- | See recvmsg(2) and sendmsg(2). -- | See recvmsg(2) and sendmsg(2). -- | See recvmsg(2) and sendmsg(2). -- | See recvmsg(2) and sendmsg(2). -- | Create a socket. The underlying file descriptor is non-blocking. All -- blocking operations are done via the GHC event manager. See -- socket(2). socket :: (SockFamily f, MonadBase IO μ) => Proxy f -> SockType -> SockProto -> μ (Socket f) -- | Get socket option value. See getsockopt(2). getSockOpt :: (SockOpt o, SockOptReadable o ~ 'True, MonadBase IO μ) => Socket f -> Proxy o -> μ (SockOptValue o) -- | Set socket option value. See setsockopt(2). setSockOpt :: (SockOpt o, SockOptWritable o ~ 'True, MonadBase IO μ) => Socket f -> Proxy o -> SockOptValue o -> μ () -- | Bind socket to the specified address. See bind(2). bind :: forall f μ. (SockFamily f, MonadBase IO μ) => Socket f -> SockFamilyAddr f -> μ () -- | Connect socket to the specified address. This operation blocks. See -- connect(2). connect :: forall f μ. (SockFamily f, MonadBase IO μ) => Socket f -> SockFamilyAddr f -> μ () -- | Try to connect socket without blocking. On success True is -- returned. If the connection did not succeed immediately, False -- is returned. See connect(2). tryConnect :: forall f μ. (SockFamily f, MonadBase IO μ) => Socket f -> SockFamilyAddr f -> μ Bool -- | Listen for connections on the given socket. See listen(2). listen :: MonadBase IO μ => Socket f -> Int -> μ () -- | Accept a connection on the given socket. This operation blocks. See -- accept(2). accept :: forall f μ. (SockFamily f, MonadBase IO μ) => Socket f -> μ (Socket f, SockFamilyAddr f) -- | Try to accept a connection on the given socket without blocking. On -- success the accepted socket and the peer address are returned. See -- accept(2). tryAccept :: forall f μ. (SockFamily f, MonadBase IO μ) => Socket f -> μ (Maybe (Socket f, SockFamilyAddr f)) -- | Get the local address. See getsockname(2). getLocalAddr :: forall f μ. (SockFamily f, MonadBase IO μ) => Socket f -> μ (SockFamilyAddr f) -- | Get the remote address. See getpeername(2). getRemoteAddr :: forall f μ. (SockFamily f, MonadBase IO μ) => Socket f -> μ (SockFamilyAddr f) -- | Check if socket has out-of-band data. See sockatmark(3). hasOobData :: MonadBase IO μ => Socket f -> μ Bool -- | Receive a message from a connected socket, possibly utilizing multiple -- memory buffers. See recvmsg(2). recvBufs :: (SockFamily f, MonadBase IO μ) => Socket f -> [(Ptr Word8, Int)] -> MsgFlags -> μ (Int, MsgFlags) -- | Receive a message from a connected socket. This operation blocks. See -- recvmsg(2). recvBuf :: (SockFamily f, MonadBase IO μ) => Socket f -> Ptr α -> Int -> MsgFlags -> μ (Int, MsgFlags) -- | Receive a message from a connected socket. This operation blocks. See -- recvmsg(2). recv' :: (SockFamily f, MonadBase IO μ) => Socket f -> Int -> MsgFlags -> μ (ByteString, MsgFlags) -- | Receive a message from a connected socket. This operation blocks. See -- recvmsg(2). recv :: (SockFamily f, MonadBase IO μ) => Socket f -> Int -> μ ByteString -- | Receive a message from an unconnected socket, possibly utilizing -- multiple memory buffers. This operation blocks. See recvmsg(2). recvBufsFrom :: forall f μ. (SockFamily f, MonadBase IO μ) => Socket f -> [(Ptr Word8, Int)] -> MsgFlags -> μ (SockFamilyAddr f, Int, MsgFlags) -- | Receive a message from an unconnected socket. This operation blocks. -- See recvmsg(2). recvBufFrom :: (SockFamily f, MonadBase IO μ) => Socket f -> Ptr α -> Int -> MsgFlags -> μ (SockFamilyAddr f, Int, MsgFlags) -- | Receive a message from an unconnected socket. This operation blocks. -- See recvmsg(2). recvFrom' :: (SockFamily f, MonadBase IO μ) => Socket f -> Int -> MsgFlags -> μ (SockFamilyAddr f, ByteString, MsgFlags) -- | Receive a message from an unconnected socket. This operation blocks. -- See recvmsg(2). recvFrom :: (SockFamily f, MonadBase IO μ) => Socket f -> Int -> μ (SockFamilyAddr f, ByteString) -- | Send a message split into several memory buffers on a connected -- socket. This operation blocks. See sendmsg(2). sendBufs :: (SockFamily f, MonadBase IO μ) => Socket f -> [(Ptr Word8, Int)] -> MsgFlags -> μ Int -- | Send a message split into several ByteStrings on a connected -- socket. This operation blocks. See sendmsg(2). sendMany' :: (SockFamily f, MonadBase IO μ) => Socket f -> [ByteString] -> MsgFlags -> μ Int -- | Send a message split into several ByteStrings on a connected -- socket. This operation blocks. See sendmsg(2). sendMany :: (SockFamily f, MonadBase IO μ) => Socket f -> [ByteString] -> μ Int -- | Send a message on a connected socket. This operation blocks. See -- sendmsg(2). sendBuf :: (SockFamily f, MonadBase IO μ) => Socket f -> Ptr α -> Int -> MsgFlags -> μ Int -- | Send a message on a connected socket. This operation blocks. See -- sendmsg(2). send' :: (SockFamily f, MonadBase IO μ) => Socket f -> ByteString -> MsgFlags -> μ Int -- | Send a message on a connected socket. This operation blocks. See -- sendmsg(2). send :: (SockFamily f, MonadBase IO μ) => Socket f -> ByteString -> μ Int -- | Send a message split into several memory buffers on an unconnected -- socket. This operation blocks. See sendmsg(2). sendBufsTo :: (SockFamily f, MonadBase IO μ) => Socket f -> [(Ptr Word8, Int)] -> MsgFlags -> SockFamilyAddr f -> μ Int -- | Send a message split into several ByteStrings on an unconnected -- socket. This operation blocks. See sendmsg(2). sendManyTo' :: (SockFamily f, MonadBase IO μ) => Socket f -> [ByteString] -> MsgFlags -> SockFamilyAddr f -> μ Int -- | Send a message split into several ByteStrings on an unconnected -- socket. This operation blocks. See sendmsg(2). sendManyTo :: (SockFamily f, MonadBase IO μ) => Socket f -> [ByteString] -> SockFamilyAddr f -> μ Int -- | Send a message on an unconnected socket. This operation blocks. See -- sendmsg(2). sendBufTo :: (SockFamily f, MonadBase IO μ) => Socket f -> Ptr α -> Int -> MsgFlags -> SockFamilyAddr f -> μ Int -- | Send a message on an unconnected socket. This operation blocks. See -- sendmsg(2). sendTo' :: (SockFamily f, MonadBase IO μ) => Socket f -> ByteString -> MsgFlags -> SockFamilyAddr f -> μ Int -- | Send a message on an unconnected socket. This operation blocks. See -- sendmsg(2). sendTo :: (SockFamily f, MonadBase IO μ) => Socket f -> ByteString -> SockFamilyAddr f -> μ Int -- | An alias for RecvSockOps. -- | An alias for SendSockOps. -- | An alias for AllSockOps. -- | Shut down a part of a full-duplex connection. See shutdown(2). shutdown :: MonadBase IO μ => Socket f -> SockOps -> μ () -- | Close the socket. See close(2). close :: MonadBase IO μ => Socket f -> μ () instance Data.Flags.Base.Flags System.Posix.Socket.MsgFlags instance Foreign.Storable.Storable System.Posix.Socket.MsgFlags instance GHC.Show.Show System.Posix.Socket.MsgFlags instance GHC.Classes.Eq System.Posix.Socket.MsgFlags instance GHC.Classes.Eq System.Posix.Socket.SockOps instance GHC.Read.Read System.Posix.Socket.SockOps instance GHC.Show.Show System.Posix.Socket.SockOps instance Foreign.Storable.Storable System.Posix.Socket.SockProto instance GHC.Show.Show System.Posix.Socket.SockProto instance GHC.Classes.Ord System.Posix.Socket.SockProto instance GHC.Classes.Eq System.Posix.Socket.SockProto instance Foreign.Storable.Storable System.Posix.Socket.SockType instance GHC.Show.Show System.Posix.Socket.SockType instance GHC.Classes.Ord System.Posix.Socket.SockType instance GHC.Classes.Eq System.Posix.Socket.SockType instance GHC.Classes.Eq (System.Posix.Socket.Socket f) instance Data.Flags.Base.Flags System.Posix.Socket.SockOps instance Data.Flags.Base.BoundedFlags System.Posix.Socket.SockOps instance System.Posix.Socket.SockOpt System.Posix.Socket.SO_REUSEADDR instance System.Posix.Socket.SockOpt System.Posix.Socket.SO_KEEPALIVE instance System.Posix.Socket.SockOpt System.Posix.Socket.SO_ERROR instance Data.Default.Class.Default System.Posix.Socket.SockProto -- | Internet address families. module System.Posix.Socket.Inet -- | IPv4 socket family. data AF_INET -- | IPv6 socket family. data AF_INET6 instance System.Posix.Socket.SockFamily System.Posix.Socket.Inet.AF_INET6 instance System.Posix.Socket.SockFamily System.Posix.Socket.Inet.AF_INET instance System.Posix.Socket.SockAddr Network.IP.Addr.Inet4Addr instance System.Posix.Socket.SockAddr Network.IP.Addr.Inet6Addr -- | Local address family. module System.Posix.Socket.Local -- | Local socket address. data LocalAddr LocalAddr :: ByteString -> LocalAddr NoLocalAddr :: LocalAddr -- | LocalAddr proxy value. aLocalAddr :: Proxy LocalAddr -- | Local socket family. data AF_LOCAL instance GHC.Show.Show System.Posix.Socket.Local.LocalAddr instance GHC.Classes.Ord System.Posix.Socket.Local.LocalAddr instance GHC.Classes.Eq System.Posix.Socket.Local.LocalAddr instance System.Posix.Socket.SockAddr System.Posix.Socket.Local.LocalAddr instance System.Posix.Socket.SockFamily System.Posix.Socket.Local.AF_LOCAL