aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--net/server_epoll.lua20
1 files changed, 14 insertions, 6 deletions
diff --git a/net/server_epoll.lua b/net/server_epoll.lua
index c450f658..c1bcbc39 100644
--- a/net/server_epoll.lua
+++ b/net/server_epoll.lua
@@ -424,12 +424,6 @@ function interface:onconnect()
self.listeners.onconnect(self);
end
-local function addclient(addr, port, listeners, pattern, tls)
- local conn, err = socket.connect(addr, port);
- if not conn then return conn, err; end
- return wrapsocket(conn, nil, pattern, listeners, tls);
-end
-
local function addserver(addr, port, listeners, pattern, tls)
local conn, err = socket.bind(addr, port, cfg.tcp_backlog);
if not conn then return conn, err; end
@@ -466,6 +460,20 @@ local function wrapclient(conn, addr, port, listeners, pattern, tls)
return client;
end
+local function addclient(addr, port, listeners, pattern, tls)
+ local conn, err = socket.connect(addr, port);
+ if not conn then return conn, err; end
+ conn:settimeout(0);
+ local client = wrapclient(conn, addr, port, listeners, pattern, tls);
+ if tls then
+ client._tls = false;
+ client:starttls();
+ else
+ client:setflags(true, true);
+ end
+ return client;
+end
+
local function link(from, to)
from.listeners = setmetatable({
onincoming = function (_, data)