module test_client import StdEnv import StdMaybe import TCPIP clientConnect :: !*World -> (!TCP_DuplexChannel, !*World) clientConnect w # (mbIPAddr, w) = lookupIPAddress "localhost" w | isNothing mbIPAddr = abort "DNS lookup failed\n" # ipAddr = fromJust mbIPAddr # (tReport, mbDuplex, w) = connectTCP_MT Nothing (ipAddr, 12345) w | tReport <> TR_Success = abort "Can't connect to port 12345\n" # duplexChannel = fromJust mbDuplex # (sChannel, w) = send (toByteSeq "Hello world!\n") duplexChannel.sChannel w duplexChannel = {duplexChannel & sChannel=sChannel} = (duplexChannel, w) Start w = clientConnect w