conduit-extra-1.3.3: Batteries included conduit: adapters for common libraries.

Safe HaskellNone
LanguageHaskell98

Data.Conduit.Network

Contents

Synopsis

Basic utilities

sourceSocket :: MonadIO m => Socket -> ConduitT i ByteString m () Source #

Stream data from the socket.

This function does not automatically close the socket.

Since 0.0.0

sinkSocket :: MonadIO m => Socket -> ConduitT ByteString o m () Source #

Stream data to the socket.

This function does not automatically close the socket.

Since 0.0.0

Simple TCP server/client interface.

data AppData #

Instances
HasReadWrite AppData 
Instance details

Defined in Data.Streaming.Network

Methods

readLens :: Functor f => (IO ByteString -> f (IO ByteString)) -> AppData -> f AppData

writeLens :: Functor f => ((ByteString -> IO ()) -> f (ByteString -> IO ())) -> AppData -> f AppData

appSource :: (HasReadWrite ad, MonadIO m) => ad -> ConduitT i ByteString m () Source #

appSink :: (HasReadWrite ad, MonadIO m) => ad -> ConduitT ByteString o m () Source #

appSockAddr :: AppData -> SockAddr #

appLocalAddr :: AppData -> Maybe SockAddr #

Server

data ServerSettings #

Instances
HasAfterBind ServerSettings 
Instance details

Defined in Data.Streaming.Network

Methods

afterBindLens :: Functor f => ((Socket -> IO ()) -> f (Socket -> IO ())) -> ServerSettings -> f ServerSettings

HasPort ServerSettings 
Instance details

Defined in Data.Streaming.Network

Methods

portLens :: Functor f => (Int -> f Int) -> ServerSettings -> f ServerSettings

HasReadBufferSize ServerSettings 
Instance details

Defined in Data.Streaming.Network

Methods

readBufferSizeLens :: Functor f => (Int -> f Int) -> ServerSettings -> f ServerSettings

runTCPServer :: ServerSettings -> (AppData -> IO ()) -> IO a #

runTCPServerWithHandle :: ServerSettings -> ConnectionHandle -> IO a #

forkTCPServer :: MonadUnliftIO m => ServerSettings -> (AppData -> m ()) -> m ThreadId Source #

Fork a TCP Server

Will fork the runGeneralTCPServer function but will only return from this call when the server is bound to the port and accepting incoming connections. Will return the thread id of the server

Since 1.1.4

runGeneralTCPServer :: MonadUnliftIO m => ServerSettings -> (AppData -> m ()) -> m a Source #

Run a general TCP server

Same as runTCPServer, except monad can be any instance of MonadUnliftIO.

Note that any changes to the monadic state performed by individual client handlers will be discarded. If you have mutable state you want to share among multiple handlers, you need to use some kind of mutable variables.

Since 1.1.3

Client

data ClientSettings #

Instances
HasPort ClientSettings 
Instance details

Defined in Data.Streaming.Network

Methods

portLens :: Functor f => (Int -> f Int) -> ClientSettings -> f ClientSettings

HasReadBufferSize ClientSettings 
Instance details

Defined in Data.Streaming.Network

Methods

readBufferSizeLens :: Functor f => (Int -> f Int) -> ClientSettings -> f ClientSettings

clientSettings :: Int -> ByteString -> ClientSettings Source #

runTCPClient :: ClientSettings -> (AppData -> IO a) -> IO a #

runGeneralTCPClient :: MonadUnliftIO m => ClientSettings -> (AppData -> m a) -> m a Source #

Run a general TCP client

Same as runTCPClient, except monad can be any instance of MonadUnliftIO.

Since 1.1.3

Getters

getPort :: HasPort a => a -> Int #

getHost :: ClientSettings -> ByteString #

getAfterBind :: HasAfterBind a => a -> Socket -> IO () #

Setters

setPort :: HasPort a => Int -> a -> a #

setAfterBind :: HasAfterBind a => (Socket -> IO ()) -> a -> a #

Types

data HostPreference #

Instances
Eq HostPreference 
Instance details

Defined in Data.Streaming.Network.Internal

Ord HostPreference 
Instance details

Defined in Data.Streaming.Network.Internal

Read HostPreference 
Instance details

Defined in Data.Streaming.Network.Internal

Methods

readsPrec :: Int -> ReadS HostPreference

readList :: ReadS [HostPreference]

readPrec :: ReadPrec HostPreference

readListPrec :: ReadPrec [HostPreference]

Show HostPreference 
Instance details

Defined in Data.Streaming.Network.Internal

Methods

showsPrec :: Int -> HostPreference -> ShowS

show :: HostPreference -> String

showList :: [HostPreference] -> ShowS

IsString HostPreference 
Instance details

Defined in Data.Streaming.Network.Internal

Methods

fromString :: String -> HostPreference