diff options
Diffstat (limited to 'tcpip/test_client.icl')
-rw-r--r-- | tcpip/test_client.icl | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tcpip/test_client.icl b/tcpip/test_client.icl new file mode 100644 index 0000000..99a0a74 --- /dev/null +++ b/tcpip/test_client.icl @@ -0,0 +1,20 @@ +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 + |