+bool InspIRCd::BindPort(ConfigTag* tag, const irc::sockets::sockaddrs& sa, std::vector<ListenSocket*>& old_ports)
+{
+ for (std::vector<ListenSocket*>::iterator n = old_ports.begin(); n != old_ports.end(); ++n)
+ {
+ if ((**n).bind_sa == sa)
+ {
+ // Replace tag, we know addr and port match, but other info (type, ssl) may not.
+ ServerInstance->Logs->Log("SOCKET", LOG_DEFAULT, "Replacing listener on %s from old tag at %s with new tag from %s",
+ sa.str().c_str(), (*n)->bind_tag->getTagLocation().c_str(), tag->getTagLocation().c_str());
+ (*n)->bind_tag = tag;
+ (*n)->ResetIOHookProvider();
+
+ old_ports.erase(n);
+ return true;
+ }
+ }
+
+ ListenSocket* ll = new ListenSocket(tag, sa);
+ if (ll->GetFd() < 0)
+ {
+ ServerInstance->Logs->Log("SOCKET", LOG_DEFAULT, "Failed to listen on %s from tag at %s: %s",
+ sa.str().c_str(), tag->getTagLocation().c_str(), strerror(errno));
+ delete ll;
+ return false;
+ }
+
+ ServerInstance->Logs->Log("SOCKET", LOG_DEFAULT, "Added a listener on %s from tag at %s", sa.str().c_str(), tag->getTagLocation().c_str());
+ ports.push_back(ll);
+ return true;
+}
+
+int InspIRCd::BindPorts(FailedPortList& failed_ports)