* or a negative value upon failure (negative values are invalid file
* descriptors)
*/
- CoreExport int OpenTCPSocket(char* addr, int socktype = SOCK_STREAM);
+ CoreExport int OpenTCPSocket(const char* addr, int socktype = SOCK_STREAM);
}
}
public:
/** Create a new listening socket
*/
- ListenSocketBase(InspIRCd* Instance, int port, char* addr);
+ ListenSocketBase(InspIRCd* Instance, int port, const std::string &addr);
/** Handle an I/O event
*/
void HandleEvent(EventType et, int errornum = 0);
{
virtual void OnAcceptReady(const std::string &ipconnectedto, int fd, const std::string &incomingip);
public:
- ClientListenSocket(InspIRCd* Instance, int port, char* addr) : ListenSocketBase(Instance, port, addr) { }
+ ClientListenSocket(InspIRCd* Instance, int port, const std::string &addr) : ListenSocketBase(Instance, port, addr) { }
};
#endif
sockaddr* ListenSocketBase::client = NULL;
sockaddr* ListenSocketBase::raddr = NULL;
-ListenSocketBase::ListenSocketBase(InspIRCd* Instance, int port, char* addr) : ServerInstance(Instance), desc("plaintext"), bind_addr(addr), bind_port(port)
+ListenSocketBase::ListenSocketBase(InspIRCd* Instance, int port, const std::string &addr) : ServerInstance(Instance), desc("plaintext"), bind_addr(addr), bind_port(port)
{
- this->SetFd(irc::sockets::OpenTCPSocket(addr));
+ this->SetFd(irc::sockets::OpenTCPSocket(addr.c_str()));
if (this->GetFd() > -1)
{
- if (!Instance->BindSocket(this->fd,port,addr))
+ if (!Instance->BindSocket(this->fd,port,addr.c_str()))
this->fd = -1;
#ifdef IPV6
- if ((!*addr) || (strchr(addr,':')))
+ if ((!*addr.c_str()) || (strchr(addr.c_str(),':')))
this->family = AF_INET6;
else
#endif
virtual void OnAcceptReady(const std::string &ipconnectedto, int nfd, const std::string &incomingip)
{
- new HttpServerSocket(ServerInstance, nfd, (char *)incomingip.c_str(), index); // XXX unsafe casts suck
+ new HttpServerSocket(ServerInstance, nfd, incomingip.c_str(), index);
}
};
}
// Open a TCP Socket
-int irc::sockets::OpenTCPSocket(char* addr, int socktype)
+int irc::sockets::OpenTCPSocket(const char* addr, int socktype)
{
int sockfd;
int on = 1;