tCall = Socket( );
tCall << Connect"www.jmp.com", "80" );
tCall << SendChar To Blob"GET / HTTP/1.0~0d~0a~0d~0a", "ASCII~HEX" ) );
tMessage = tCall << Recv1000 );
text = Blob To Char( tMessage[3] );
Show( text );
tCall << Close( );
The first line creates a socket and gives it a reference name (tCall). By default, a stream socket is created. You can designate the type of socket to create with an optional argument: socket(STREAM) or socket(DGRAM).
The second line connects the tCall socket to port 80 (which is generally the HTTP port) of the JMP website.
The third line sends a GET request to the JMP web server; this message tells the JMP web server to send the JMP home page back. The / that follows the word GET should be the path to the page to be opened. A / opens the root page.
The fourth line receives up to 1000 bytes from the JMP web server and stores a list of information in tMessage. Each socket call returns a list. The first element of the list is the name of the call, and the second is a text message, which might be ok or a longer diagnostic message. Additional elements, if present, are specific to the call. In this case, the third element in the list is the data received.
The fifth line converts the binary information received into a character string. tMessage[3] is the third item in the list returned by Recv; it is the data from the JMP web server.
The JMP Samples/Scripts folder contains several examples of scripts using sockets.