// 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); } } }
See also:
send_data, socket_receive, socket_connect