summaryrefslogtreecommitdiff
path: root/ConduitServer.hs
diff options
context:
space:
mode:
Diffstat (limited to 'ConduitServer.hs')
-rw-r--r--ConduitServer.hs21
1 files changed, 19 insertions, 2 deletions
diff --git a/ConduitServer.hs b/ConduitServer.hs
index 4b28194e..0838ce26 100644
--- a/ConduitServer.hs
+++ b/ConduitServer.hs
@@ -6,7 +6,10 @@ import Data.Conduit.Network
6import Data.Conduit 6import Data.Conduit
7import qualified Data.Conduit.List as CL 7import qualified Data.Conduit.List as CL
8import qualified Data.ByteString.Char8 as S 8import qualified Data.ByteString.Char8 as S
9import qualified Data.ByteString.Lazy.Char8 as L 9
10import Network.Socket (Family(..))
11import Data.HList
12import ServerC
10 13
11{- 14{-
12data AppData m = AppData 15data AppData m = AppData
@@ -24,8 +27,22 @@ handleConnection appdata = do
24 sourceLbs "<stream>\n" $$ appSink appdata -- send bytestring 27 sourceLbs "<stream>\n" $$ appSink appdata -- send bytestring
25 appSource appdata $$ CL.mapM_ S.putStrLn -- display inbound bytestring 28 appSource appdata $$ CL.mapM_ S.putStrLn -- display inbound bytestring
26 29
27main = do 30mainOld = do
28 -- Listen to port 5222 and invoke handleConnection on every 31 -- Listen to port 5222 and invoke handleConnection on every
29 -- inbound connection. 32 -- inbound connection.
30 runTCPServer (serverSettings 5222 HostAny) handleConnection 33 runTCPServer (serverSettings 5222 HostAny) handleConnection
31 return () 34 return ()
35
36
37
38
39handleC st src snk = do
40 sourceLbs "<stream>\n" $$ snk
41 src $$ CL.mapM_ S.putStrLn
42
43mainC = do
44 doServer (AF_INET .*. 5222 .*. HNil) handleC
45 _ <- getLine
46 return ()
47
48main = mainC