3 As for net001 but gets the system to allocate the next free port
4 number. It also prints out the IP number of the peer.
18 socket AF_INET Stream 6 >>= \ s ->
19 bindSocket s (SockAddrInet aNY_PORT iNADDR_ANY) >>
20 getSocketName s >>= \ (SockAddrInet port _) ->
21 putStr ("Allocated Port Number: " ++ show port ++ "\n") >>
27 accept s >>= \ (s',(SockAddrInet _ haddr)) ->
28 putStr ("*** Start of Transfer from: " ++
29 (inet_ntoa haddr) ++ "***\n") >>
32 readSocket s' 4 >>= \ (str, nbytes) ->
37 putStr "\n*** End of Transfer ***\n" >>