Thank you to anyone who has already donated - your generous donations helped make three months of treatment possible.

My brother Nate continues to fight stage IV Hodgkin's lymphoma. He's just 31, with a wife and baby girl. They have no active income (since he's been unable to return to work), no insurance, and cannot afford the treatment he needs. Nate and his family need your help. Please consider a donation, every dollar helps. Thanks.



			
#!/usr/bin/env ruby
require 'socket'

opt = [5, 0].pack("i,i")

sock = Socket.new(Socket::AF_INET, Socket::SOCK_STREAM, 0)
sockaddr = Socket.pack_sockaddr_in(3232, '127.0.0.1')

sock.setsockopt(Socket::SOL_SOCKET, Socket::SO_RCVTIMEO, opt)
puts "sockopt = #{sock.getsockopt(Socket::SOL_SOCKET, Socket::SO_RCVTIMEO).inspect}"

sock.connect(sockaddr)

#this tells the server at 192.168.1.10:3232 to wait 4 seconds before responding, then send some data, then wait another 4 before sending the newline -- so we should get a timeout on our socket -- after having read some of the data
sock.write("4\r\n")

start_time = Time.now
begin
  result = sock.recvfrom(8192)
rescue Errno::EAGAIN
  puts "got timeout -- current state of the code this won't get hit because recvfrom isn't looking for a newline, just reads the first bit of data sent"
end
time = Time.now - start_time

puts "read: #{result.inspect} after: #{time} seconds"
#timeout occured, this read returns after 4 seconds

#note -- this is testing against a server running, sample code for server here: http://pastie.org/314915