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