Can anyone help me with this ruby script right, I am trying to connect using ruby script What I tried:
Ruby version: ruby 2.7.3p183 (2021-04-05 revision 6847ee089d) [x86_64-linux-gnu]
*require 'socket'
socket = TCPSocket 172.16.5.10 7707*
error :rbexp.rb:3: unexpected fraction part after numeric literal ...ket = TCPSocket.new 172.16.5.10, 7707
关于unexpected fraction part after numeric literal
错误unexpected fraction part after numeric literal
:ruby 将 172.16.5.10 解析为数字文字 - 使用字符串“172.16.5.10”。
A very simple way of solving your issue is as follows:
require 'socket'
socket = TCPSocket.new "172.16.5.10", 7707
while line = socket.gets
puts line
end
socket.close
puts "Bye!"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.