Comparison

core/s2smanager.lua @ 960:6bc16062da6c

core.s2smanager: Check for valid host and port before attempting connection
author Matthew Wild <mwild1@gmail.com>
date Mon, 06 Apr 2009 23:43:48 +0100
parent 959:e3db909065f2
child 963:43b140edfd84
comparison
equal deleted inserted replaced
959:e3db909065f2 960:6bc16062da6c
175 host_session.log("debug", "Out of connection options, can't connect to %s", tostring(host_session.to_host)); 175 host_session.log("debug", "Out of connection options, can't connect to %s", tostring(host_session.to_host));
176 -- We're out of options 176 -- We're out of options
177 return false; 177 return false;
178 end 178 end
179 179
180 if not (connect_host and connect_port) then
181 -- Likely we couldn't resolve DNS
182 return false;
183 end
184
180 -- Ok, we're going to try to connect 185 -- Ok, we're going to try to connect
181 conn:settimeout(0); 186 conn:settimeout(0);
182 local success, err = conn:connect(connect_host, connect_port); 187 local success, err = conn:connect(connect_host, connect_port);
183 if not success and err ~= "timeout" then 188 if not success and err ~= "timeout" then
184 log("warn", "s2s connect() failed: %s", err); 189 log("warn", "s2s connect() failed: %s", err);