From $ROOTSYS/tutorials/net/hserv.C

void hserv() {
   // Server program which waits for two clients to connect. It then monitors
   // the sockets and displays the objects it receives. To see how to
   // make a non-blocking server see the script hserv2.C.
   //
   // To run this demo do the following:
   //   - Open three windows
   //   - Start ROOT in all three windows
   //   - Execute in the first window: .x hserv.C
   //   - Execute in the second and third windows: .x hclient.C
   //Author: Fons Rademakers

   // Open a server socket looking for connections on a named service or
   // on a specified port.
   //TServerSocket *ss = new TServerSocket("rootserv", kTRUE);
   TServerSocket *ss = new TServerSocket(9090, kTRUE);

   // Accept a connection and return a full-duplex communication socket.
   TSocket *s0 = ss->Accept();
   TSocket *s1 = ss->Accept();

   // tell the clients to start
   s0->Send("go 0");
   s1->Send("go 1");

   // Close the server socket (unless we will use it later to wait for
   // another connection).
   ss->Close();

   // Check some options of socket 0.
   int val;
   s0->GetOption(kSendBuffer, val);
   printf("sendbuffer size: %d\n", val);
   s0->GetOption(kRecvBuffer, val);
   printf("recvbuffer size: %d\n", val);

   // Get the remote addresses (informational only).
   TInetAddress adr = s0->GetInetAddress();
   adr.Print();
   adr = s1->GetInetAddress();
   adr.Print();

   // Create canvas and pads to display the histograms
   TCanvas *c1 = new TCanvas("c1","The Ntuple canvas",200,10,700,780);
   TPad *pad1 = new TPad("pad1","This is pad1",0.02,0.52,0.98,0.98,21);
   TPad *pad2 = new TPad("pad2","This is pad2",0.02,0.02,0.98,0.48,21);
   pad1->Draw();
   pad2->Draw();

   TMonitor *mon = new TMonitor;

   mon->Add(s0);
   mon->Add(s1);

   while (1) {
      TMessage *mess;
      TSocket  *s;

      s = mon->Select();

      s->Recv(mess);

      if (mess->What() == kMESS_STRING) {
         char str[64];
         mess->ReadString(str, 64);
         printf("Client %d: %s\n", s==s0 ? 0 : 1, str);
         mon->Remove(s);
         if (mon->GetActive() == 0) {
            printf("No more active clients... stopping\n");
            break;
         }
      } else if (mess->What() == kMESS_OBJECT) {
         //printf("got object of class: %s\n", mess->GetClass()->GetName());
         TH1 *h = (TH1 *)mess->ReadObject(mess->GetClass());
         if (h) {
            if (s == s0)
               pad1->cd();
            else
               pad2->cd();
            h->Print();
            h->DrawCopy();  //draw a copy of the histogram, not the histo itself
            c1->Modified();
            c1->Update();
            delete h;       // delete histogram
         }
      } else {
         printf("*** Unexpected message ***\n");
      }

      delete mess;
   }

   printf("Client 0: bytes recv = %d, bytes sent = %d\n", s0->GetBytesRecv(),
          s0->GetBytesSent());
   printf("Client 1: bytes recv = %d, bytes sent = %d\n", s1->GetBytesRecv(),
          s1->GetBytesSent());

   // Close the socket.
   s0->Close();
   s1->Close();
}
 hserv.C:1
 hserv.C:2
 hserv.C:3
 hserv.C:4
 hserv.C:5
 hserv.C:6
 hserv.C:7
 hserv.C:8
 hserv.C:9
 hserv.C:10
 hserv.C:11
 hserv.C:12
 hserv.C:13
 hserv.C:14
 hserv.C:15
 hserv.C:16
 hserv.C:17
 hserv.C:18
 hserv.C:19
 hserv.C:20
 hserv.C:21
 hserv.C:22
 hserv.C:23
 hserv.C:24
 hserv.C:25
 hserv.C:26
 hserv.C:27
 hserv.C:28
 hserv.C:29
 hserv.C:30
 hserv.C:31
 hserv.C:32
 hserv.C:33
 hserv.C:34
 hserv.C:35
 hserv.C:36
 hserv.C:37
 hserv.C:38
 hserv.C:39
 hserv.C:40
 hserv.C:41
 hserv.C:42
 hserv.C:43
 hserv.C:44
 hserv.C:45
 hserv.C:46
 hserv.C:47
 hserv.C:48
 hserv.C:49
 hserv.C:50
 hserv.C:51
 hserv.C:52
 hserv.C:53
 hserv.C:54
 hserv.C:55
 hserv.C:56
 hserv.C:57
 hserv.C:58
 hserv.C:59
 hserv.C:60
 hserv.C:61
 hserv.C:62
 hserv.C:63
 hserv.C:64
 hserv.C:65
 hserv.C:66
 hserv.C:67
 hserv.C:68
 hserv.C:69
 hserv.C:70
 hserv.C:71
 hserv.C:72
 hserv.C:73
 hserv.C:74
 hserv.C:75
 hserv.C:76
 hserv.C:77
 hserv.C:78
 hserv.C:79
 hserv.C:80
 hserv.C:81
 hserv.C:82
 hserv.C:83
 hserv.C:84
 hserv.C:85
 hserv.C:86
 hserv.C:87
 hserv.C:88
 hserv.C:89
 hserv.C:90
 hserv.C:91
 hserv.C:92
 hserv.C:93
 hserv.C:94
 hserv.C:95
 hserv.C:96
 hserv.C:97
 hserv.C:98
 hserv.C:99
 hserv.C:100
 hserv.C:101
 hserv.C:102