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 // We don't really need anything special in this class here, we could simply use Socket directly
15 class SampleSocket : Socket
20 SampleSocket socket { };
22 class TXApp : GuiApplication
26 if(socket.Connect("localhost", samplePort))
28 // We build up a SamplePacket here with our message
29 String string = "Hello !";
30 int len = strlen(string);
31 int size = sizeof(SamplePacket) + len;
32 SamplePacket * packet = (SamplePacket *)new byte[size];
33 packet->stringLen = len;
34 memcpy(packet->string, string, len+1);
36 socket.Send(packet, size);
38 // Make sure to free memory allocated with 'new'