-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Reflex bindings for TCP sockets -- -- -- reflex-backend-socket provides functions to handle sockets using -- Reflex Events. Sending/receiving/waiting/accepting are all -- performed on background threads. -- -- The most important function in this library is -- Reflex.Backend.Socket.socket, which wraps a Socket -- to process Event t ByteStrings. -- -- That Socket can come from: -- --
    --
  1. Reflex.Backend.Socket.Accept.accept, if you're making a -- server;
  2. --
  3. Reflex.Backend.Socket.Connect.connect, if you're making a -- client; or
  4. --
  5. Your favourite networking library.
  6. --
@package reflex-backend-socket @version 0.2.0.1 module Reflex.Backend.Socket.Error -- | If a "socket setup" fails (accept or connect), you'll -- inspect one of these to find out why. data SetupError -- | Call to getAddrInfo failed. GetAddrInfoError :: IOException -> SetupError -- | We failed to set up a socket with any AddrInfo we were given, -- and here are the corresponding exceptions each time we tried. For -- accept, this means either bind or listen failed, -- and for connect, this means Connect failed. UseAddrInfoError :: NonEmpty (AddrInfo, IOException) -> SetupError _GetAddrInfoError :: Prism' SetupError IOException _UseAddrInfoError :: Prism' SetupError (NonEmpty (AddrInfo, IOException)) instance GHC.Show.Show Reflex.Backend.Socket.Error.SetupError instance GHC.Generics.Generic Reflex.Backend.Socket.Error.SetupError instance GHC.Classes.Eq Reflex.Backend.Socket.Error.SetupError -- | Use connect to attempt a connection to a remote endpoint, and -- get an Event t (Either SetupError -- Socket) that tells you whether or not it worked. module Reflex.Backend.Socket.Connect -- | Connect to a remote endpoint. The connection happens in a background -- thread. connect :: (Reflex t, PerformEvent t m, TriggerEvent t m, PostBuild t m, MonadIO (Performable m), MonadIO m) => Maybe HostName -> ServiceName -> m (Event t (Either SetupError Socket)) -- | Use accept to create listen sockets, and get an -- Event t Socket of new connections. module Reflex.Backend.Socket.Accept -- | Create a listening socket. Sockets are accepted in a background -- thread. accept :: (Reflex t, PerformEvent t m, PostBuild t m, TriggerEvent t m, MonadIO (Performable m), MonadIO m) => AcceptConfig t -> m (Event t (Either SetupError (Accept t))) -- | Configuration of a listen socket. data AcceptConfig t AcceptConfig :: Maybe HostName -> Maybe ServiceName -> Int -> [(SocketOption, Int)] -> Event t () -> AcceptConfig t -- | The hostname to bind to. This will often be Nothing, to bind -- all interfaces. [_acHostname] :: AcceptConfig t -> Maybe HostName -- | The port number or service name to listen on. See the manpage for -- getaddrinfo. [_acService] :: AcceptConfig t -> Maybe ServiceName -- | The length of the "pending connections" queue. See the manpage for -- listen. [_acListenQueue] :: AcceptConfig t -> Int -- | List of socket options, passed one at a time to -- setSocketOption. Many people will want [(ReuseAddr, -- 1)] here. [_acSocketOptions] :: AcceptConfig t -> [(SocketOption, Int)] -- | Close the listen socket when this event fires. If you plan to run -- forever, use never. [_acClose] :: AcceptConfig t -> Event t () -- | Events produced by a running listen socket. data Accept t Accept :: Event t (Socket, SockAddr) -> Event t () -> Event t IOException -> Accept t -- | A new connection was accepted, including its remote address. [_aAcceptSocket] :: Accept t -> Event t (Socket, SockAddr) -- | The socket has closed. This will fire exactly once when the socket -- closes for any reason, including if your _acClose event fires -- or if the socket closes in response to a caught exception. [_aClose] :: Accept t -> Event t () -- | An exception occurred. Treat the socket as closed after you see this. -- You will see the _aClose event fire as well, but not -- necessarily in the same frame. [_aError] :: Accept t -> Event t IOException acHostname :: forall t_agh1. Lens' (AcceptConfig t_agh1) (Maybe HostName) acService :: forall t_agh1. Lens' (AcceptConfig t_agh1) (Maybe ServiceName) acListenQueue :: forall t_agh1. Lens' (AcceptConfig t_agh1) Int acSocketOptions :: forall t_agh1. Lens' (AcceptConfig t_agh1) [(SocketOption, Int)] acClose :: forall t_agh1 t_agj4. Lens (AcceptConfig t_agh1) (AcceptConfig t_agj4) (Event t_agh1 ()) (Event t_agj4 ()) aAcceptSocket :: forall t_agjO. Lens' (Accept t_agjO) (Event t_agjO (Socket, SockAddr)) aClose :: forall t_agjO. Lens' (Accept t_agjO) (Event t_agjO ()) aError :: forall t_agjO. Lens' (Accept t_agjO) (Event t_agjO IOException) -- | Use socket to wrap a network Socket so that it sends out -- the firings of an Event t ByteString, and fires -- any data that it receives on another Event t -- ByteString. module Reflex.Backend.Socket -- | Wire a socket into the FRP network. You will likely use this to attach -- events to a socket that you just connected (from connect), or a -- socket that you just accepted (from the _aAcceptSocket event -- you got when you called accept). socket :: forall t m. (Reflex t, PerformEvent t m, PostBuild t m, TriggerEvent t m, MonadIO (Performable m), MonadIO m) => SocketConfig t -> m (Socket t) -- | Holds the socket to wire into the FRP network, and events that drive -- it. data SocketConfig t SocketConfig :: Socket -> Int -> Event t ByteString -> Event t () -> SocketConfig t -- | Socket to wrap. [_scInitSocket] :: SocketConfig t -> Socket -- | Maximum number of bytes to read at a time. [_scMaxRx] :: SocketConfig t -> Int -- | Data to send out on this socket. [_scSend] :: SocketConfig t -> Event t ByteString -- | Ask to close the socket. The socket will stop trying to receive data -- (and the _sReceive event will stop firing), and the socket will -- be "drained": future events on _scSend will be ignored, and it -- will close after writing all pending data. If _scSend and -- _scClose fire in the same frame, the data will nevertheless be -- queued for sending. [_scClose] :: SocketConfig t -> Event t () -- | Events produced by an active socket. data Socket t Socket :: Event t ByteString -> Event t () -> Event t () -> Event t IOException -> Socket t -- | Data has arrived. [_sReceive] :: Socket t -> Event t ByteString -- | The socket has opened, and its receive/send loops are running. [_sOpen] :: Socket t -> Event t () -- | The socket has closed. This will fire exactly once when the socket -- closes for any reason, including if your _scClose event fires, -- the other end disconnects, or if the socket closes in response to a -- caught exception. [_sClose] :: Socket t -> Event t () -- | An exception occurred. Treat the socket as closed after you see this. -- If the socket was open, you will see the _sClose event fire as -- well, but not necessarily in the same frame. [_sError] :: Socket t -> Event t IOException scInitSocket :: forall t_aiEN. Lens' (SocketConfig t_aiEN) Socket scMaxRx :: forall t_aiEN. Lens' (SocketConfig t_aiEN) Int scSend :: forall t_aiEN. Lens' (SocketConfig t_aiEN) (Event t_aiEN ByteString) scClose :: forall t_aiEN. Lens' (SocketConfig t_aiEN) (Event t_aiEN ()) sReceive :: forall t_aiHJ. Lens' (Socket t_aiHJ) (Event t_aiHJ ByteString) sOpen :: forall t_aiHJ. Lens' (Socket t_aiHJ) (Event t_aiHJ ()) sClose :: forall t_aiHJ. Lens' (Socket t_aiHJ) (Event t_aiHJ ()) sError :: forall t_aiHJ. Lens' (Socket t_aiHJ) (Event t_aiHJ IOException)