/usr/share/doc/ruby-packet/examples/write_bulk.rb is in ruby-packet 0.1.15-5.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | require "socket"
require "thread"
# sock = TCPSocket.open("localhost",11007)
#data = File.open("netbeans.jpg").read
data = File.open("nginx.dat").read
# p data.length
threads = []
500.times do
# sock.write(data)
# select([sock],nil,nil,nil)
# read_data = ""
# loop do
# begin
# while(read_data << sock.read_nonblock(1023)); end
# rescue Errno::EAGAIN
# break
# rescue
# break
# end
# end
threads << Thread.new do
sock = TCPSocket.open("localhost",11007)
# p read_data.length
written_length = sock.write(data)
p "Write Length: #{written_length}"
read_length = sock.read(written_length)
p "Read length: #{read_length.length}"
end
# # p read_data.length
# written_length = sock.write(data)
# #p "Write Length: #{written_length}"
# read_length = sock.read(written_length)
# #p "Read length: #{read_length.length}"
end
threads.each { |x| x.join }
|