Software /
code /
verse
Comparison
init.lua @ 399:82ad158714e5
Merge with Zash
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Tue, 12 Jan 2016 13:14:36 +0000 |
parent | 369:074c547fe05a |
parent | 385:e6bf19ad5c19 |
child | 411:db462d4feb44 |
comparison
equal
deleted
inserted
replaced
378:6042c938e369 | 399:82ad158714e5 |
---|---|
23 | 23 |
24 function verse.init(...) | 24 function verse.init(...) |
25 for i=1,select("#", ...) do | 25 for i=1,select("#", ...) do |
26 local ok, err = pcall(require, "verse."..select(i,...)); | 26 local ok, err = pcall(require, "verse."..select(i,...)); |
27 if not ok then | 27 if not ok then |
28 error("Verse connection module not found: verse."..select(i,...).."\n"..err); | 28 error("Verse connection module not found: verse."..select(i,...)..err); |
29 end | 29 end |
30 end | 30 end |
31 return verse; | 31 return verse; |
32 end | 32 end |
33 | 33 |
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; |