diff options
Diffstat (limited to 'ConduitServer.hs')
-rw-r--r-- | ConduitServer.hs | 21 |
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 | |||
6 | import Data.Conduit | 6 | import Data.Conduit |
7 | import qualified Data.Conduit.List as CL | 7 | import qualified Data.Conduit.List as CL |
8 | import qualified Data.ByteString.Char8 as S | 8 | import qualified Data.ByteString.Char8 as S |
9 | import qualified Data.ByteString.Lazy.Char8 as L | 9 | |
10 | import Network.Socket (Family(..)) | ||
11 | import Data.HList | ||
12 | import ServerC | ||
10 | 13 | ||
11 | {- | 14 | {- |
12 | data AppData m = AppData | 15 | data 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 | ||
27 | main = do | 30 | mainOld = 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 | |||
39 | handleC st src snk = do | ||
40 | sourceLbs "<stream>\n" $$ snk | ||
41 | src $$ CL.mapM_ S.putStrLn | ||
42 | |||
43 | mainC = do | ||
44 | doServer (AF_INET .*. 5222 .*. HNil) handleC | ||
45 | _ <- getLine | ||
46 | return () | ||
47 | |||
48 | main = mainC | ||