3 // We'll use TCP/IP port 5623 for this sample
4 define samplePort = 5623;
6 // We will use this simple structure for our messages
10 // stringLen + 1 bytes are actually used (variable size depending on string)
14 class SampleService : Service
18 // When we get an incoming connection to our service, we spawn a SampleSocket
19 SampleSocket { this };
23 class SampleSocket : Socket
25 unsigned int OnReceive(unsigned char * buffer, unsigned int count)
27 // We only process the data if we've received enough bytes to make up the message
28 // This first if just checks if we have reveived enough bytes for the header
29 if(count >= sizeof(SamplePacket))
31 SamplePacket * packet = (SamplePacket *) buffer;
32 uint size = sizeof(SamplePacket) + packet->stringLen;
33 // Here we check if we've actually received the entire message
36 // We've received a complete message, so we change the contents of the recvString EditBox
37 log.PutS(packet->string);
39 // and we return the size of the message we've processed.
40 // If more data is already buffered, this method will be called again right away.
44 // We haven't received enough data to process this message yet: return 0 bytes processed
45 // This method will be called again once more data has been received.
51 SampleService service { port = samplePort };
55 caption = "RX Sample";
63 class RXApp : GuiApplication