I’m new to socket programming.
On QRTP timeout for socket read/write could be done this way?
For read:
TimerTimeout(CLOCK_REALTIME,_NTO_TIMEOUT_REPLY, NULL, &mytimeout,NULL);
n = recv(mysock, &mydata, sizeof(mydata), 0);
if (n < 0)
{
if (errno==EINTR)
{
/* timed out */
}
}
For write:
TimerTimeout(CLOCK_REALTIME,_NTO_TIMEOUT_REPLY, NULL, &mytimeout,NULL);
n = send(mysock, &mydata, sizeof(mydata), 0);
if (n < 0)
{
if (errno==EINTR)
{
/* timed out */
}
}
Any trouble using sockets like this?
Thanks.
Maurizio Rossi
System S.p.A.
Yes, you can timeout socket call like this.
Except I would suggest using
“_NTO_TIMEOUT_SEND | _NTO_TIMEOUT_REPLY”
for sure.
-xtang
Maurizio Rossi <mauri_ros@libero.it> wrote:
I’m new to socket programming.
On QRTP timeout for socket read/write could be done this way?
For read:
TimerTimeout(CLOCK_REALTIME,_NTO_TIMEOUT_REPLY, NULL, &mytimeout,NULL);
n = recv(mysock, &mydata, sizeof(mydata), 0);
if (n < 0)
{
if (errno==EINTR)
{
/* timed out */
}
}
For write:
TimerTimeout(CLOCK_REALTIME,_NTO_TIMEOUT_REPLY, NULL, &mytimeout,NULL);
n = send(mysock, &mydata, sizeof(mydata), 0);
if (n < 0)
{
if (errno==EINTR)
{
/* timed out */
}
}
Any trouble using sockets like this?
Thanks.
Maurizio Rossi
System S.p.A.