Software /
code /
verse
Comparison
init.lua @ 382:479b856a910f
verse: Enable TCP keepalives
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Tue, 05 May 2015 01:08:20 +0200 |
parent | 368:154c2f04d73b |
child | 385:e6bf19ad5c19 |
comparison
equal
deleted
inserted
replaced
381:65533afab352 | 382:479b856a910f |
---|---|
117 connect_port = tonumber(connect_port) or 5222; | 117 connect_port = tonumber(connect_port) or 5222; |
118 | 118 |
119 -- Create and initiate connection | 119 -- Create and initiate connection |
120 local conn = socket.tcp() | 120 local conn = socket.tcp() |
121 conn:settimeout(0); | 121 conn:settimeout(0); |
122 conn:setoption("keepalive", true); | |
122 local success, err = conn:connect(connect_host, connect_port); | 123 local success, err = conn:connect(connect_host, connect_port); |
123 | 124 |
124 if not success and err ~= "timeout" then | 125 if not success and err ~= "timeout" then |
125 self:warn("connect() to %s:%d failed: %s", connect_host, connect_port, err); | 126 self:warn("connect() to %s:%d failed: %s", connect_host, connect_port, err); |
126 return self:event("disconnected", { reason = err }) or false, err; | 127 return self:event("disconnected", { reason = err }) or false, err; |