Basically I need a TCP-IP socket connection, as described
in the manual.
Where I can send raw bytestreams to and from
another socket (wich could be either a gamestudio plugin or
Java).
Important is, that the connection behaves like a raw socket
connection (without any automatic initialisation data send
back and forth, so basically having no predefined protocol)
so that the serversocket can be implemented in
any other enviroment, not just to comunicate between
two instances of the dll.
// Control a GALEP device by sending script commands to its GalepX socket
STRING* strScript = // command script that lets GALEP blink its LEDs
"#include \"gxAPI/gxBasic1.h\"
string s = gxGetCurrentEndDevice();
gxDeviceIdentity(s);
";
TEXT* txtReceive = { flags = SHOW; }
function main()
{
// open a TCP socket on GalepX port 1233
if (!socket_connect("localhost",1233,1)) {
printf("Can't connect to GalepX!");
} else
{
// send the script to the socket
var size = str_len(strScript);
var sent = socket_send(_chr(strScript),size);
if (sent) txt_addstring(txtReceive,strScript);
// display the response
while(1) {
char input[1000];
int received = socket_receive(input,1000);
if (received > 0) {
input[received] = 0; // add the end mark
txt_addstring(txtReceive,input);
}
wait(1);
}
}
}