second-transfer-0.10.0.4: Second Transfer HTTP/2 web server

Safe HaskellNone
LanguageHaskell2010

SecondTransfer.IOCallbacks.SocketServer

Contents

Synopsis

Documentation

data SocketIOCallbacks

IOCallbacks around an active socket

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.

Socket server with iterators

tcpItcli :: Socket -> Source IO (Socket, SockAddr)

Itcli is a word made from ITerate-on-CLIents. This function makes an iterated listen...