Socket reading/writing with send/recv works :

============================================
# encode: utf-8

require "thread"
require 'socket'
require 'gserver'

Thread.abort_on_exception=true

$stdout.sync=true
class Tcp_Server < GServer
  def serve( io )
    io.set_encoding 'ASCII-8BIT'
    until io.closed?
      size=io.recv(4).to_i
      data= io.recv(size)
      if data.size==size
        puts "received : '#{Marshal.load(data).join(", ")}"
      else
        puts "strange size received #{data.size}"
      end
      io.send('a')
    end
  end
end
th=Tcp_Server.new(2244,"localhost")
th.start        # Start server

Thread.new {
  sleep(0.8)
  a=["starting","式汐竹", "式汐老糸", "汐而老汍耒而汐", "汐而老汍耒而汍", 
"汐聿汍糸","Ending"]
  puts a.join(" ")
  buff=Marshal.dump(a)
  socket = TCPSocket.new("localhost",2244)
  socket.set_encoding 'ASCII-8BIT'
  socket.send("%4d" % [buff.size],0)
  socket.send(buff,0)
  socket.flush
  socket.recv(1)
  socket.close
}


th.join
==========================================================
>ruby utf8.rb
starting 式汐竹 式汐老糸 汐而老汍耒而汐 汐而老汍耒而汍 汐聿汍糸 Ending
received : 'starting, 式汐竹, 式汐老糸, 汐而老汍耒而汐, 汐而老汍耒而汍, 汐聿汍糸, Ending

--