As my previous reply statement any call made via the Readline() (for now) or a iostream will block if the sender dont close the connection or send a delimeter that we look for, expample getline() even if you specified
if (ispending(SOCKET_INPUT_TIMEOUT, 1000)
myTcpStream.getline(buffer, buffersize)
the problem is the istream calls underflow when he reach the end of get buffer which is ok. But in the underflow it remakes a calls to recv() which block.
so my suggestion.
a public method setTimeout(myTimeout)
in the underflow
if (rlen)
if (ispending(SOCKET_INPUT_TIMEOUT, ..)
rlen = recv(...)
else
rlen = -1
end if
so because, the logic behind a stream is to have an abstraction of the primitive of the socket. so now to make a call to a tcpstream it will lokk
myTcpStream.setTimeout(myTimeOut)
myTcpStream.getline(buffer, bufferSize)
myTcpStream.getLine(buffer, bufferSize)...
etc... whitout calling isPending each time.
secondo in underflow() while putting the state of stream to failbit the errid should updated.
Error(SOCKET_INPUIT_ERROR)
marco
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I think this suggestion is essentially correct. I will look into an implimentation based on what you outline here, unless you have a patch to send already.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
As my previous reply statement any call made via the Readline() (for now) or a iostream will block if the sender dont close the connection or send a delimeter that we look for, expample getline() even if you specified
if (ispending(SOCKET_INPUT_TIMEOUT, 1000)
myTcpStream.getline(buffer, buffersize)
the problem is the istream calls underflow when he reach the end of get buffer which is ok. But in the underflow it remakes a calls to recv() which block.
so my suggestion.
a public method setTimeout(myTimeout)
in the underflow
if (rlen)
if (ispending(SOCKET_INPUT_TIMEOUT, ..)
rlen = recv(...)
else
rlen = -1
end if
so because, the logic behind a stream is to have an abstraction of the primitive of the socket. so now to make a call to a tcpstream it will lokk
myTcpStream.setTimeout(myTimeOut)
myTcpStream.getline(buffer, bufferSize)
myTcpStream.getLine(buffer, bufferSize)...
etc... whitout calling isPending each time.
secondo in underflow() while putting the state of stream to failbit the errid should updated.
Error(SOCKET_INPUIT_ERROR)
marco
I think this suggestion is essentially correct. I will look into an implimentation based on what you outline here, unless you have a patch to send already.