Forum Discussion
Altera_Forum
Honored Contributor
14 years agoHi,
It works well !! code is :
if ((fd_listen = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0)
{
alt_NetworkErrorHandler(EXPANDED_DIAGNOSIS_CODE," Socket creation failed");
}
sockval = 1;
if (setsockopt(fd_listen, SOL_SOCKET, SO_KEEPALIVE, &sockval, sizeof(sockval)) == -1)
{
printf("Warning : KeepAlive option set failed\n");
} and when the function is call recv(), capture the rx_code : if ==-1
rx_code = recv(conn->fd, conn->rx_wr_pos,
SSS_RX_BUF_SIZE - (conn->rx_wr_pos - conn->rx_buffer) -1, 0);
if(rx_code > 0)
{
conn->rx_wr_pos += rx_code;
/* Zero terminate so we can use string functions */
*(conn->rx_wr_pos+1) = 0;
}
else if(rx_code == -1) // Case of timeout lost TCP connection
{
conn->close = 1;
} My mistake was in not capture the returned code from recv(). I hope it will help somebody else.