gameServer/stresstest2.hs
changeset 2948 3f21a9dc93d0
parent 2352 7eaf82cf0890
child 3947 709fdb89f76c
equal deleted inserted replaced
2947:803b277e4894 2948:3f21a9dc93d0
    13 #if !defined(mingw32_HOST_OS)
    13 #if !defined(mingw32_HOST_OS)
    14 import System.Posix
    14 import System.Posix
    15 #endif
    15 #endif
    16 
    16 
    17 testing = Control.Exception.handle print $ do
    17 testing = Control.Exception.handle print $ do
    18 	delay <- randomRIO (100::Int, 300)
    18     delay <- randomRIO (100::Int, 300)
    19 	threadDelay delay
    19     threadDelay delay
    20 	sock <- connectTo "127.0.0.1" (PortNumber 46631)
    20     sock <- connectTo "127.0.0.1" (PortNumber 46631)
    21 	hClose sock
    21     hClose sock
    22 
    22 
    23 forks i = do
    23 forks i = do
    24 	delay <- randomRIO (50::Int, 190)
    24     delay <- randomRIO (50::Int, 190)
    25 	if i `mod` 10 == 0 then putStr (show i) else putStr "."
    25     if i `mod` 10 == 0 then putStr (show i) else putStr "."
    26 	hFlush stdout
    26     hFlush stdout
    27 	threadDelay delay
    27     threadDelay delay
    28 	forkIO testing
    28     forkIO testing
    29 	forks (i + 1)
    29     forks (i + 1)
    30 
    30 
    31 main = withSocketsDo $ do
    31 main = withSocketsDo $ do
    32 #if !defined(mingw32_HOST_OS)
    32 #if !defined(mingw32_HOST_OS)
    33 	installHandler sigPIPE Ignore Nothing;
    33     installHandler sigPIPE Ignore Nothing;
    34 #endif
    34 #endif
    35 	forks 1
    35     forks 1