Example of Client-Socket communication

{
   // Connect to a service or port on a remote host. Either use the
   // hostname or the IP address as a string.

   //TSocket *s = new TSocket("pcrdm", "rootserv");
   //TSocket *s = new TSocket("pcrdm", 9090);
   //TSocket *s = new TSocket("128.141.186.61", 9090);
   TSocket *s = new TSocket("localhost", 9090);

   // Get the local and remote addresses (informational only).
   TInetAddress adr = s->GetLocalInetAddress();
   adr.Print();
   adr = s->GetInetAddress();
   adr.Print();

   // Send 10 simple string messages.
   char str[256];
   for (int i = 0; i < 10; i++) {
      sprintf(str, "message %d", i);
      s->Send(str);
   }

   // Send some ROOT commands.
   s->Send(".ls", kMESS_CINT);
   s->Send(".q", kMESS_CINT);

   // Close the socket.
   s->Close();
}


ROOT page - Class index - Top of the page

This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.