我想使用Rubys TCPSocket-Class发送原始字节.有人举个好榜样吗?
我试过这种方式,但它不起作用:(
require 'socket'
host = '192.168.0.80'
port = 102
s = TCPSocket.new(host, port)
s.write [0x03, 0x00, 0x00, 0x16,
0x11, 0xE0, 0x00, 0x00, 0x00,
0x01, 0x00, 0xC1, 0x02, 0x02,
0x02, 0xC2, 0x02, 0x02, 0x02,
0xC0, 0x01, 0x0A ].pack('C')
puts s.read
s.close
puts "exit"
Run Code Online (Sandbox Code Playgroud)
谢谢 :)