-// Open a TCP Socket
-int irc::sockets::OpenTCPSocket(const char* addr, int socktype)
-{
- int sockfd;
- int on = 1;
- addr = addr;
- struct linger linger = { 0, 0 };
-#ifdef IPV6
- if (!*addr)
- {
- sockfd = socket (PF_INET6, socktype, 0);
- if (sockfd < 0)
- sockfd = socket (PF_INET, socktype, 0);
- }
- else if (strchr(addr,':'))
- sockfd = socket (PF_INET6, socktype, 0);
- else
- sockfd = socket (PF_INET, socktype, 0);
- if (sockfd < 0)
-#else
- if ((sockfd = socket (PF_INET, socktype, 0)) < 0)
-#endif
- {
- return ERROR;
- }
- else
- {
- setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, (char*)&on, sizeof(on));
- /* This is BSD compatible, setting l_onoff to 0 is *NOT* http://web.irc.org/mla/ircd-dev/msg02259.html */
- linger.l_onoff = 1;
- linger.l_linger = 1;
- setsockopt(sockfd, SOL_SOCKET, SO_LINGER, (char*)&linger,sizeof(linger));
- return (sockfd);
- }
-}
-
-// XXX: it would be VERY nice to genericize this so all listen stuff (server/client) could use the one function. -- w00t
-int InspIRCd::BindPorts(bool, int &ports_found, FailedPortList &failed_ports)