aboutsummaryrefslogtreecommitdiff
path: root/test/find-connect-limit
diff options
context:
space:
mode:
authorSam Roberts <vieuxtech@gmail.com>2011-06-28 17:48:21 -0700
committerSam Roberts <vieuxtech@gmail.com>2012-04-11 13:45:59 -0700
commitdace50628c5acc0aad94538eb6d3bd31e055d941 (patch)
treef6bef53b628fafeba459fd8e83e4057c0982deb9 /test/find-connect-limit
parentf63d616bc048fe256181ff5e7e4aaca11afe3237 (diff)
downloadluasocket-dace50628c5acc0aad94538eb6d3bd31e055d941.tar.gz
luasocket-dace50628c5acc0aad94538eb6d3bd31e055d941.tar.bz2
luasocket-dace50628c5acc0aad94538eb6d3bd31e055d941.zip
Utility to find how many TCP connections can be made.
Diffstat (limited to 'test/find-connect-limit')
-rwxr-xr-xtest/find-connect-limit32
1 files changed, 32 insertions, 0 deletions
diff --git a/test/find-connect-limit b/test/find-connect-limit
new file mode 100755
index 0000000..ad0c3f5
--- /dev/null
+++ b/test/find-connect-limit
@@ -0,0 +1,32 @@
1#!/usr/bin/env lua
2--[[
3Find out how many TCP connections we can make.
4
5Use ulimit to increase the max number of descriptors:
6
7ulimit -n 10000
8ulimit -n
9
10You'll probably need to be root to do this.
11]]
12
13require "socket"
14
15host = arg[1] or "google.com"
16port = arg[2] or 80
17
18connections = {}
19
20repeat
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
31until false
32