I have a issue in reading from Sockets(both TCPSockets and
UNIXSockets).the
problem is with following code snippets:
begin
timeout(8) do ret_data = @proxy_con.gets() end rescue Timeout::Error return nil rescue Exception => e return nil end
The problem is, since read(or gets) from socket blocks the thread(or
process), i do a timeout on it.and return nil to the client.Now the next
time, the client puts some request, i put it to the socket and do a
gets. So
what happens is I get data for the previous request, because i guess the
socket buffer was not cleared up( or whatever name people use for this).
Can i use noblock on TCPSockets/UNIXSockets?
I guess, its a pretty basic problem, but how do i go about solving this?