-#include "inspstring.h"
-#include "helperfuncs.h"
-#include "socketengine.h"
-#include "message.h"
-
-extern InspIRCd* ServerInstance;
-extern ServerConfig* Config;
-extern time_t TIME;
-extern int openSockfd[MAX_DESCRIPTORS];
-
-InspSocket* socket_ref[MAX_DESCRIPTORS];
-
-/** This will bind a socket to a port. It works for UDP/TCP.
- * If a hostname is given to bind to, the function will first
- * attempt to resolve the hostname, then bind to the IP the
- * hostname resolves to. This is a blocking lookup blocking for
- * a maximum of one second before it times out, using the DNS
- * server specified in the configuration file.
- */
-bool BindSocket(int sockfd, insp_sockaddr client, insp_sockaddr server, int port, char* addr)
-{
- memset(&server,0,sizeof(server));
- insp_inaddr addy;
- bool resolved = false;
- char resolved_addr[128];
-
- if (*addr == '*')
- *addr = 0;
-
- if (*addr && !inet_aton(addr,&addy))
- {
- /* If they gave a hostname, bind to the IP it resolves to */
- if (CleanAndResolve(resolved_addr, addr, true))
- {
- inet_aton(resolved_addr,&addy);
- log(DEFAULT,"Resolved binding '%s' -> '%s'",addr,resolved_addr);
- server.sin_addr = addy;
- resolved = true;
- }
- else
+
+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)