Hi,
I have a pragram that create a channel between two sockets (kind of proxy).
Everything i read from one socket is writen to the other.
I use select to see if there is something to read on either one or the
other socket.
The main loop looks like this:
while(1){
FD_ZERO(fds);
FD_SET(socket_to,fds);
FD_SET(socket_client,fds);
select(socket_client+1,fds,NULL,NULL,NULL);
if(FD_ISSET(socket_client,fds)){
r=recv(socket_client,buf,BUFSZ,0);
send(socket_to,buf,r,0);
}
if(FD_ISSET(socket_to,fds)){
r=recv(socket_to,buf,BUFSZ,0);
send(socket_client,buf,r,0);
}
}
When i made my test using an http server on one side and a telnet
client on the other side. I tested sending an http get command, all
goes well but after the the server reply is done, the select always
return 1 saying there is something to be read from the socket_to (http
serveur) but the recv call always return 0.
I can't understand were is my fault. (this should be my fault but i
can't understand that the select says there is something to be read,
and that when reading there is nothing... and its keep looping)
Thanks
A+
--
Fabrice Gautier