[[3D]]
* サンプルクライアント by ruby [#k5a101ca]
 require 'socket'
 
 class Client
  attr :socket
 
  def open(host)
    @socket = TCPSocket.open(host, 3100)
  end
 
  def close
    @socket.close
  end
 
  def send(msg)
    str = [msg.length].pack('N') + msg
    @socket.write(str)
  end
 
  def recv
    nsize = @socket.read(4)
    size = nsize.unpack('N')
    @socket.read(size[0])
  end
 end
 
 # Main
 client = Client.new
 client.open 'localhost'
 
 Thread.start {
  # output to STDOUT
  while true
    puts client.recv
  end
 }
 
 # input from STDIN
 while true
  l = gets
  client.send l
 end

* usage [#s439d534]
 
 $ ruby sample-agent.rb > /tmp/xxx.log
 (scene rsg/agent/nao/nao.rsg)
 (init (unum 0) (team RR))

* 組込Ruby参考 [#e830860a]

- [[SWIG:http://www.swig.org/]]
- [[RubyEmbed:http://raa.ruby-lang.org/project/rubyembed/]]



トップ   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS