From: Ryan Davis Date: 2010-12-07T08:06:11+09:00 Subject: Re: Vortex Level0 with Ruby On Dec 6, 2010, at 13:52 , Eugeni Akmuradov wrote: > socket = TCPSocket::new( "vortex.labs.overthewire.org", 5842 ) > data=Array.new > s=0 > > 4.times do > data = data + socket.recvfrom(4) > end > data.compact! > puts "complete string #{data.inspect}" > data.each { |x| s += x.unpack('L')[0] ; print x.unpack('L')[0], " " } > puts > socket.write s > puts socket.read > socket.close > > And it do not solve the subject, please help me to understand where i's > my mistake. Your code, while ugly, is mostly correct from what I can see. A couple suggestions: 1) you're unpacking with "L", which is only correct if you're on the same architecture as the server (little endian). You should use "V" instead to be portable. 2) You're sending back ... what? You may want to implement the echo server from the TCPServer chapter in the pickaxe to see what's going on exactly. Here is my solution: > class Socket > def self.open(*args) # 'cuz I don't like ugly > f = self.class.new(*args) > yield f > f.close > end > end > > TCPSocket.open("vortex.labs.overthewire.org", 5842) do |s| > auth = s.read(16).unpack("V4").inject { |sum, n| sum + n } > s.write [auth].pack("V") > pass = s.read > p pass > end