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
void hserv() {
int val;
printf("sendbuffer size: %d\n", val);
printf("recvbuffer size: %d\n", val);
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);
while (1) {
char str[64];
printf("Client %d: %s\n", s==s0 ? 0 : 1, str);
printf("No more active clients... stopping\n");
break;
}
if (h) {
if (s == s0)
else
}
} else {
printf("*** Unexpected message ***\n");
}
delete mess;
}
printf(
"Client 0: bytes recv = %d, bytes sent = %d\n", s0->
GetBytesRecv(),
printf(
"Client 1: bytes recv = %d, bytes sent = %d\n", s1->
GetBytesRecv(),
}
- Author
- Fons Rademakers
Definition in file hserv.C.