From f6e857c1f4c6ac34760755508ed861a29b51d791 Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Sat, 19 Mar 2016 22:39:11 +0100 Subject: TCPIP --- tcpip/test_client.icl | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 tcpip/test_client.icl (limited to 'tcpip/test_client.icl') 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 + -- cgit v1.2.3