As test echo server use udpserver.c in the same directory.
To compile it do:
clang udpserver.c -o udpserver
int testTUDPSocket()
{
printf("testTSocket: Creating TUDPSocket\n");
if (!fSocket || !fSocket->
IsValid()) {
Error(
"testTSocket",
"cannot connect to localhost");
return -1;
}
TString msg =
"testTSocket: Testing TSocket with UDP";
printf(
"%s\n",msg.
Data());
Error(
"testTSocket",
"error sending command to host %s", fServer.GetHost());
return -1;
}
char msgRaw[1024] = {0};
if (recvBytes == -1){
Error(
"testTSocket",
"error receiving data from host %s", fServer.GetHost());
return -1;
}
printf("Received Message: \n%s\n",msgRaw);
return 1;
}
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
const char * Data() const
virtual Int_t RecvRaw(void *buffer, Int_t length, ESendRecvOptions opt=kDefault)
Receive a raw buffer of specified length bytes.
virtual Bool_t IsValid() const
virtual Int_t SetOption(ESockOptions opt, Int_t val)
Set socket options.
virtual Int_t Select(Int_t interest=kRead, Long_t timeout=-1)
Waits for this socket to change status.
virtual Int_t SendRaw(const void *buffer, Int_t length, ESendRecvOptions opt=kDefault)
Send a raw buffer of specified length.
- Author
Definition in file testTUDPSocket.C.