I know exactly what i need to do, but i cant do it properly...

TCPSocket.open("209.172.49.193",6115) {|sock|
#send the server my name 01010101010101
sock.print(["f71e2d00c50d00300000000000e0170900000001010101010101000100020017d7c0a8016b0000000000000000"].pack("H*"))


#when i watch tcp dump, the server will send me "f70108009a3571cf"
#the last 4 bytes of that string i need to send back to the server to
keep connection alive...
while
sock.print(["f7010800#{gets.chomp}"].pack("H*"))
end
}
# i can keep this connection alive by watching tcpdump, and passing the
value to GETS...



i have been at this for weeks now trying to read from the socket then
print to the socket...

i cant do both at the same time...

as soon as i stop reading from the socket the connection is reset...
data=(sock.gets.unpack("H*"))
if data.to_s.include?("f7010800") == true
ping=data.to_s.index("f7010800")
sock.print(["#{data.to_s[ping..ping+15]}"].pack("H*"))

-- 
Posted via http://www.ruby-forum.com/.