Safe Haskell | None |
---|---|
Language | Haskell2010 |
- data SocketIOCallbacks
- newtype TLSServerSocketIOCallbacks = TLSServerSocketIOCallbacks SocketIOCallbacks
- createAndBindListeningSocket :: String -> Int -> IO Socket
- createAndBindListeningSocketNSSockAddr :: SockAddr -> IO Socket
- socketIOCallbacks :: Socket -> IO SocketIOCallbacks
- tcpServe :: Socket -> (Socket -> IO ()) -> IO ()
- tlsServe :: Socket -> (TLSServerSocketIOCallbacks -> IO ()) -> IO ()
- tcpItcli :: Socket -> Source IO (Socket, SockAddr)
- tlsItcli :: Socket -> Source IO (TLSServerSocketIOCallbacks, SockAddr)
Documentation
data SocketIOCallbacks
IOCallbacks around an active socket
newtype TLSServerSocketIOCallbacks
Simple alias to SocketIOCallbacks where we expect encrypted contents
createAndBindListeningSocket :: String -> Int -> IO Socket
Creates a listening socket at the provided network address (potentially a local interface) and the given port number. It returns the socket. This result can be used by the function tcpServe below
createAndBindListeningSocketNSSockAddr :: SockAddr -> IO Socket
Same as above, but it takes a pre-built address
socketIOCallbacks :: Socket -> IO SocketIOCallbacks
This function wraps an active socket (e.g., one where it is possible to send and receive data) in something with a set of active callbacks
Socket server with callbacks
tcpServe :: Socket -> (Socket -> IO ()) -> IO ()
Simple TCP server. You must give a very short action, as the action is run straight in the calling thread. For a typical server, you would be doing a forkIO in the provided action. Do prefer to use tcpItcli directly.
tlsServe :: Socket -> (TLSServerSocketIOCallbacks -> IO ()) -> IO ()
Convenience function to create a TLS server. You are in charge of actually setting up the TLS session, this only receives a type tagged with the IO thing... Notice that the action should be short before actually forking towards something doing the rest of the conversation. If you do the TLS handshake in this thread, you will be in trouble when more than one client try to handshake simultaeneusly... ibidem if one of the clients blocks the handshake.