def write_msg(socket, msg)
      sio = StringIO.new('', 'r+')
      len = msg.serialize(sio)
      sio.rewind
      data = sio.read
      len = data.length
      data = [len, data].pack("La#{len}")
      socket.write(data)
      data
    end
def write_msg(socket, msg)
      sio = StringIO.new('', 'r+')
      len = msg.serialize(sio)
      sio.rewind
      data = sio.read
      len = data.length
      data = [len, data].pack("La#{len}")
      socket.write(data)
      data
    end
write message to socket.
 @param [IO] socket socket for writing
 @param [Message] msg message for writing
 @return [String] wrote data