> TCPSocket#send and TCPSocket#write are functionally same.

I think #write will block until all the data is sent, whereas #send
may return immediately, having sent only part of the data.

With #send you may need a loop like this:

  def send_string(sock, str)
    begin
      while str.length > 0
        sent = sock.send(str, 0)
        str = str[sent..-1]
      end
    rescue IOError, SocketError, SystemCallError
      # eof = true
    end
  end


Regards,

Bill