Z
zb011 message
Hi all,
I have coded an outbound Socket program in C on a solaris box that
sends out data and receives an acknowledgement for it.
However, have faced this problem of a "HANG" state, whereby the read()
function does not return any values.
===========code attached=============================
int readn(int fd, char *ptr)
{
int ntot, nread, found, sr; //sr added 11th May
char *start_posn, *end_posn;
start_posn = ptr;
found = 0;
ntot = 0;
nread = read(fd, ptr, 1); <===read does not return. "HANG STATE"
if (nread < 0)
{
if (found)
return -43;
else
return -42;
}
else if (nread == 0)
{
log(nread,"break from loop","",read_ini_file());
break;
}
============================================================
The required action was to stop and restart the socket.
Have tried to intercept this with a select() (to check on the socket)
However, with a select() 2sec is to be set for the timeval.
This will greatly cripple the performance and thus causing us to be
reluctant in adding this code.
Would be good if someone is able to explain why read() does not return
a vaule when there is no data to be read on the socket.
Thanks!
I have coded an outbound Socket program in C on a solaris box that
sends out data and receives an acknowledgement for it.
However, have faced this problem of a "HANG" state, whereby the read()
function does not return any values.
===========code attached=============================
int readn(int fd, char *ptr)
{
int ntot, nread, found, sr; //sr added 11th May
char *start_posn, *end_posn;
start_posn = ptr;
found = 0;
ntot = 0;
nread = read(fd, ptr, 1); <===read does not return. "HANG STATE"
if (nread < 0)
{
if (found)
return -43;
else
return -42;
}
else if (nread == 0)
{
log(nread,"break from loop","",read_ini_file());
break;
}
============================================================
The required action was to stop and restart the socket.
Have tried to intercept this with a select() (to check on the socket)
However, with a select() 2sec is to be set for the timeval.
This will greatly cripple the performance and thus causing us to be
reluctant in adding this code.
Would be good if someone is able to explain why read() does not return
a vaule when there is no data to be read on the socket.
Thanks!