author | unc0rr |
Mon, 16 Aug 2010 18:43:32 +0400 | |
changeset 3741 | 73246d25dfe1 |
parent 2948 | 3f21a9dc93d0 |
child 3947 | 709fdb89f76c |
permissions | -rw-r--r-- |
1804 | 1 |
{-# LANGUAGE CPP #-} |
2 |
||
3 |
module Main where |
|
4 |
||
5 |
import IO |
|
6 |
import System.IO |
|
7 |
import Control.Concurrent |
|
8 |
import Network |
|
9 |
import Control.Exception |
|
10 |
import Control.Monad |
|
11 |
import System.Random |
|
12 |
||
13 |
#if !defined(mingw32_HOST_OS) |
|
14 |
import System.Posix |
|
15 |
#endif |
|
16 |
||
2352 | 17 |
testing = Control.Exception.handle print $ do |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2352
diff
changeset
|
18 |
delay <- randomRIO (100::Int, 300) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2352
diff
changeset
|
19 |
threadDelay delay |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2352
diff
changeset
|
20 |
sock <- connectTo "127.0.0.1" (PortNumber 46631) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2352
diff
changeset
|
21 |
hClose sock |
1804 | 22 |
|
23 |
forks i = do |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2352
diff
changeset
|
24 |
delay <- randomRIO (50::Int, 190) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2352
diff
changeset
|
25 |
if i `mod` 10 == 0 then putStr (show i) else putStr "." |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2352
diff
changeset
|
26 |
hFlush stdout |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2352
diff
changeset
|
27 |
threadDelay delay |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2352
diff
changeset
|
28 |
forkIO testing |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2352
diff
changeset
|
29 |
forks (i + 1) |
1804 | 30 |
|
31 |
main = withSocketsDo $ do |
|
32 |
#if !defined(mingw32_HOST_OS) |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2352
diff
changeset
|
33 |
installHandler sigPIPE Ignore Nothing; |
1804 | 34 |
#endif |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2352
diff
changeset
|
35 |
forks 1 |