author | Xeli |
Thu, 17 May 2012 16:52:17 +0200 | |
changeset 7087 | d2089f2ea5af |
parent 4932 | f11d80bac7ed |
child 10460 | 8dcea9087d75 |
permissions | -rw-r--r-- |
1804 | 1 |
{-# LANGUAGE CPP #-} |
2 |
||
3 |
module Main where |
|
4 |
||
5 |
import System.IO |
|
6 |
import Control.Concurrent |
|
7 |
import Network |
|
4905 | 8 |
import Control.OldException |
1804 | 9 |
import Control.Monad |
10 |
import System.Random |
|
11 |
||
12 |
#if !defined(mingw32_HOST_OS) |
|
13 |
import System.Posix |
|
14 |
#endif |
|
15 |
||
4905 | 16 |
session1 nick room = ["NICK", nick, "", "PROTO", "32", ""] |
17 |
||
18 |
||
19 |
||
20 |
testing = Control.OldException.handle print $ do |
|
21 |
putStrLn "Start" |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2352
diff
changeset
|
22 |
sock <- connectTo "127.0.0.1" (PortNumber 46631) |
1804 | 23 |
|
4905 | 24 |
num1 <- randomRIO (70000::Int, 70100) |
25 |
num2 <- randomRIO (0::Int, 2) |
|
26 |
num3 <- randomRIO (0::Int, 5) |
|
27 |
let nick1 = 'n' : show num1 |
|
28 |
let room1 = 'r' : show num2 |
|
29 |
mapM_ (\x -> hPutStrLn sock x >> hFlush sock >> randomRIO (300::Int, 590) >>= threadDelay) $ session1 nick1 room1 |
|
30 |
mapM_ (\x -> hPutStrLn sock x >> hFlush sock) $ concatMap (\x -> ["CHAT_MSG", show x, ""]) [1..] |
|
31 |
hClose sock |
|
32 |
putStrLn "Finish" |
|
33 |
||
34 |
forks = testing |
|
1804 | 35 |
|
36 |
main = withSocketsDo $ do |
|
37 |
#if !defined(mingw32_HOST_OS) |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2352
diff
changeset
|
38 |
installHandler sigPIPE Ignore Nothing; |
1804 | 39 |
#endif |
4905 | 40 |
forks |