| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
System.Semaphore.Internal.DomainSocket
Synopsis
- connectDomainSocket :: FilePath -> IO Fd
- listenDomainSocket :: FilePath -> IO Fd
- pollAcceptSocket :: Fd -> Fd -> IO AcceptResult
- data AcceptResult
- = AcceptedFd !Fd
- | AcceptCancelled
- fdReadByte :: HasCallStack => Fd -> IO Word8
- fdWriteByte :: HasCallStack => Fd -> Word8 -> IO ()
- fdShutdown :: Fd -> IO ()
Documentation
connectDomainSocket :: FilePath -> IO Fd Source #
listenDomainSocket :: FilePath -> IO Fd Source #
Open a socket in non blocking mode (O_NONBLOCK)
pollAcceptSocket :: Fd -> Fd -> IO AcceptResult Source #
Block until either a client connects or the cancel fd is written to.
Relies on cooperative cancellation implemented in hs_poll_accept using
poll(2) + accept(2) via safe FFI to avoid GHC #27110 and #27113.
Must be called from a masked context. The caller is responsible for installing an exception handler that closes all 3 fds (inputs and outputs).
data AcceptResult Source #
Result of pollAcceptSocket.
Constructors
| AcceptedFd !Fd | A client connected; here is the fd. |
| AcceptCancelled | The cancel pipe was signalled. |
fdReadByte :: HasCallStack => Fd -> IO Word8 Source #
Read a single byte from a file descriptor.
Throws an EOF IOError if the peer has disconnected.
fdWriteByte :: HasCallStack => Fd -> Word8 -> IO () Source #
Write a single byte to a file descriptor.
fdShutdown :: Fd -> IO () Source #
Shut down a socket for both reading and writing.
A concurrent fdReadByte on the same fd will return immediately
Used to cancel threads blocked in read()