3 As net003 but uses the BSD module for portability. Also prints the
4 common name of the host rather than its IP number.
19 getProtocolNumber "tcp" >>= \ proto ->
20 socket AF_INET Stream proto >>= \ s ->
21 bindSocket s (SockAddrInet aNY_PORT iNADDR_ANY) >>
22 getSocketName s >>= \ (SockAddrInet port _) ->
23 putStr ("Allocated Port Number: " ++ show port ++ "\n") >>
29 accept s >>= \ (s',(SockAddrInet _ haddr)) ->
30 getHostByAddr AF_INET haddr >>= \ (HostEntry hname _ _ _) ->
31 putStr ("*** Start of Transfer from: " ++ hname ++ "***\n") >>
34 readSocket s' 4 >>= \ (str, nbytes) ->
39 putStr "\n*** End of Transfer ***\n" >>