From ff0f488c97fe8b554b909a0057cebc4c860eac8f Mon Sep 17 00:00:00 2001 From: chai Date: Wed, 20 Oct 2021 13:40:34 +0800 Subject: +luasocket src --- ThirdParty/luasocket/test/find-connect-limit | 32 ++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 ThirdParty/luasocket/test/find-connect-limit (limited to 'ThirdParty/luasocket/test/find-connect-limit') diff --git a/ThirdParty/luasocket/test/find-connect-limit b/ThirdParty/luasocket/test/find-connect-limit new file mode 100644 index 0000000..199e515 --- /dev/null +++ b/ThirdParty/luasocket/test/find-connect-limit @@ -0,0 +1,32 @@ +#!/usr/bin/env lua +--[[ +Find out how many TCP connections we can make. + +Use ulimit to increase the max number of descriptors: + +ulimit -n 10000 +ulimit -n + +You'll probably need to be root to do this. +]] + +socket = require "socket" + +host = arg[1] or "google.com" +port = arg[2] or 80 + +connections = {} + +repeat + c = assert(socket.connect(hostip or host, 80)) + table.insert(connections, c) + + if not hostip then + hostip = c:getpeername() + print("resolved", host, "to", hostip) + end + + print("connection #", #connections, c, "fd", c:getfd()) + +until false + -- cgit v1.1-26-g67d0