diff options
author | Camil Staps | 2016-03-19 22:39:11 +0100 |
---|---|---|
committer | Camil Staps | 2016-03-19 22:39:11 +0100 |
commit | f6e857c1f4c6ac34760755508ed861a29b51d791 (patch) | |
tree | 6126e9bf3509699e9b84e25a2796b2b0b8824045 /tcpip/test_client.icl | |
parent | restricted existentially qualified type (diff) |
TCPIP
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 + |