summaryrefslogtreecommitdiff
path: root/tcpip/test_client.icl
blob: 99a0a7406d4a3d6714a070163bbed0b7e51a4107 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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