NETACCEPTRECEIVEVALUE

Synopsis
NETACCEPTRECEIVEVALUE
Description

Outputs the value of the last network data received on the connection created with NETACCEPTON. The output is a list, as if parsed by PARSE.

The network data is interpreted as characters encoded in the system default Windows code page of the host operating system. As a result, it may not be possible to receive data from an instance of FMSLogo that is running on an operating system which is configured for a different language than yours.

It is best to call this procedure in your receiveready callback code of your NETACCEPTON instruction. If you don't, then the data is discarded the next time receiveready is run.

FMSLogo does not guarantee that the remote machine that sent the data is friendly. It is therefore a good practice to make sure that the data looks correct before using it. For example, if you want to accept turtle commands from a remote machine, its bad to simply RUN all data that you receive, as the data could include a SHELL command that installs malware. Instead, your program should verify that the data it received is a well-formed turtle command before running it.

Example

This example sets up both a client and server. The client (connector) sends data to the server (accepter).

NETSTARTUP ; Start up the network

; Wait for someone to connect to you on local port 5124
SHOW NETACCEPTON 5124 [] [PRINT NETACCEPTRECEIVEVALUE]
true

; Connect to local machine on port 5124
; If you want to run this portion on a different computer, then replace
; the "localhost with the name of the other computer.
SHOW NETCONNECTON "localhost 5124 [PRINT [Ok to Send Again]] []
true

WAIT 100 ; Wait little for connection to establish
Ok to Send Again
Ok to Send Again
Ok to Send Again
SHOW NETCONNECTSENDVALUE [Hello thanks for taking my call] ; Send some data
true

WAIT 100 ; Wait a little before we shut things down
Hello thanks for taking my call

NETCONNECTOFF
NETACCEPTOFF
NETSHUTDOWN


SourceForge.net Logo