find-connect-limit 573 B

1234567891011121314151617181920212223242526272829303132
  1. #!/usr/bin/env lua
  2. --[[
  3. Find out how many TCP connections we can make.
  4. Use ulimit to increase the max number of descriptors:
  5. ulimit -n 10000
  6. ulimit -n
  7. You'll probably need to be root to do this.
  8. ]]
  9. require "socket"
  10. host = arg[1] or "google.com"
  11. port = arg[2] or 80
  12. connections = {}
  13. repeat
  14. c = assert(socket.connect(hostip or host, 80))
  15. table.insert(connections, c)
  16. if not hostip then
  17. hostip = c:getpeername()
  18. print("resolved", host, "to", hostip)
  19. end
  20. print("connection #", #connections, c, "fd", c:getfd())
  21. until false