TCP Client

TCP Client

There are two methods for making a TCP connection to another server. The first method uses the
OPEN
command while the second method uses the
CLIENTSOCKET
method.
CLIENTSOCKET
is the preferred method.
Example
The following example demonstrates this method:
10 CLOSE ALL 20 LET INPORT = CLIENTSOCKET("TCP","192.168.0.1",9100) 40 LET OUTSTR$ = "REQUESTING SERVER NAME"; 50 DO WHILE (LEN(OUTSTR$) > 0) 60 LET BYTES_WRITTEN = WRITE(INPORT,OUTSTR$,LEN(OUTSTR$)) 70 ON ERROR GOTO RECOVERY 80 LET OUTSTR$ = OUTSTR$(1+BYTES_WRITTEN:LEN(OUTSTR$)) 90 LOOP 100 INPUT #INPORT: YOURNAME$ 110 PRINT #INPORT: "Server returned: "; YOURNAME$ 120 CLOSE #INPORT 130 SUB RECOVERY 140 END