From: Brian Candler Date: 2011-03-17T06:30:47+09:00 Subject: Re: TCPSocket, send always transmit an even length message I think you're using the wrong method. 'send' is a inherited method of BasicSocket, and calls 'sendto' in the underlying O/S. And the second argument is actually flags, not length. /* * call-seq: * basicsocket.send(mesg, flags [, dest_sockaddr]) => numbytes_sent * * send _mesg_ via _basicsocket_. * * _mesg_ should be a string. * * _flags_ should be a bitwise OR of Socket::MSG_* constants. * * _dest_sockaddr_ should be a packed sockaddr string or an addrinfo. * * TCPSocket.open("localhost", 80) {|s| * s.send "GET / HTTP/1.0\r\n\r\n", 0 * p s.read * } */ Try setting flags to zero instead and it'll probably work: >> require 'socket' => true >> rx = TCPServer.new('127.0.0.1',2000) => # >> tx = TCPSocket.new('127.0.0.1',2000) => # >> s = rx.accept => # >> tx.send('ab', 0) => 2 >> tx.send('cde', 0) => 3 >> s.readpartial(1024) => "abcde" >> RUBY_DESCRIPTION => "ruby 1.8.7 (2010-06-23 patchlevel 299) [x86_64-linux]" >> But really you should just be using 'write' not 'send', unless you're trying to do something funky like sending out-of-band data (MSG_OOB) -- Posted via http://www.ruby-forum.com/.