This script shows how to make a simple iterative server that can accept connections while handling currently open connections.
{
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);
"_hserv2._tcp", ""), 9090);
while (1) {
} else
printf("only accept two client connections\n");
}
continue;
}
char str[64];
printf(
"Client %d: %s\n",
s==
s0 ? 0 : 1, str);
printf("No more active clients... stopping\n");
break;
}
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(),
}
char * Form(const char *fmt,...)
R__EXTERN TSystem * gSystem
Int_t RegisterService(const TBonjourRecord &record, UShort_t servicePort)
Register Bonjour service.
virtual TObject * ReadObject(const TClass *cl)
Read object from I/O buffer.
virtual char * ReadString(char *s, Int_t max)
Read string from I/O buffer.
TClass * GetClass() const
TSocket * Select()
Return pointer to socket for which an event is waiting.
virtual void Add(TSocket *sock, Int_t interest=kRead)
Add socket to the monitor's active list.
Int_t GetActive(Long_t timeout=-1) const
Return number of sockets in the active list.
virtual void Remove(TSocket *sock)
Remove a socket from the monitor.
The most important graphics class in the ROOT system.
virtual void Draw(Option_t *option="")
Draw Pad in Current pad (re-parent pad if necessary).
TVirtualPad * cd(Int_t subpadnumber=0)
Set Current pad.
virtual void Close(Option_t *opt="")
Close the socket.
virtual const char * HostName()
Return the system's host name.
static constexpr double s