summaryrefslogtreecommitdiff
path: root/testsuite/tests/lib/socket/socket005.hs
blob: ec504aa480acee1143260c118651cd356b7daf0f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
{- server

Server as net001 but for Unix Domain Datagram sockets.

TESTS:
    socket
    bindSocket
    readSocket

-}


module Main where

import SocketPrim


main =
    socket AF_UNIX Datagram 0			>>= \ s ->
    bindSocket s (SockAddrUnix "sock")		>>

    let 
      loop = 
	putStr "*** Start of Transfer ***\n"	>>
	let 
	  read_all = 
	    readSocket s 1024			>>= \ (str, nbytes) ->
	    if nbytes /= 0 then
		putStr str			>>
		read_all
	    else
		putStr "\n*** End of Transfer ***\n"
	in
	    read_all    
    in
	loop