Hi chaps, I am trying to read an HTTP packet via a socket in ruby, and for some reason my code keeps on blocking whilst calling recv
socket = TCPSocket.new("localhost",80)
socket.send r.join("\r\n"), 0
socket.flush
#We're only interested in the string "HTTP/1.1 XXX"
if http_status = get_http_status(socket.recv_nonblock(12))
if http_status == 200
$logger.info "Wrote #{message_packet}"
else
$logger.warn "Resubmitting message because #{line} is not 200"
@queue.publish(message)
end
end
#Get rid of the rest of the content
the_rest = socket.recv(1000)
while(the_rest != "") do
the_rest = socket.recv(1000)
end
From what I understand of recv
it should return nothing if there's no data waiting on the socket?