X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Flistensocket.cpp;h=e0a18a043fab7a86bafe734fa8f463e1c28ccb73;hb=060f4034303f798ee0a55a926c2c2a120b865df4;hp=823cb9ecacdf45565798c3869ce0ede9a8f779ef;hpb=347dcb9ef44e19e2e2613ee7e8c7d5fbb0aca4ca;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/listensocket.cpp b/src/listensocket.cpp index 823cb9eca..e0a18a043 100644 --- a/src/listensocket.cpp +++ b/src/listensocket.cpp @@ -21,43 +21,43 @@ irc::sockets::sockaddrs ListenSocketBase::client; irc::sockets::sockaddrs ListenSocketBase::server; -ListenSocketBase::ListenSocketBase(InspIRCd* Instance, int port, const std::string &addr) : ServerInstance(Instance), desc("plaintext") +ListenSocketBase::ListenSocketBase(int port, const std::string &addr, const std::string &Type, const std::string &Hook) + : type(Type), hook(Hook), bind_port(port) { irc::sockets::sockaddrs bind_to; // canonicalize address if it is defined - if (!irc::sockets::aptosa(addr.c_str(), port, &bind_to)) + if (!irc::sockets::aptosa(addr, port, &bind_to)) { // malformed address bind_addr = addr; - bind_port = port; bind_desc = addr + ":" + ConvToStr(port); this->fd = -1; } else { - irc::sockets::satoap(&bind_to, bind_addr, bind_port); + irc::sockets::satoap(&bind_to, bind_addr, port); bind_desc = irc::sockets::satouser(&bind_to); - this->fd = irc::sockets::OpenTCPSocket(bind_addr.c_str()); + this->fd = irc::sockets::OpenTCPSocket(bind_addr); } if (this->fd > -1) { - int rv = Instance->SE->Bind(this->fd, &bind_to.sa, sizeof(bind_to)); + int rv = ServerInstance->SE->Bind(this->fd, &bind_to.sa, sizeof(bind_to)); if (rv >= 0) - rv = Instance->SE->Listen(this->fd, Instance->Config->MaxConn); + rv = ServerInstance->SE->Listen(this->fd, ServerInstance->Config->MaxConn); if (rv < 0) { - Instance->SE->Shutdown(this, 2); - Instance->SE->Close(this); + ServerInstance->SE->Shutdown(this, 2); + ServerInstance->SE->Close(this); this->fd = -1; } else { - Instance->SE->NonBlocking(this->fd); - Instance->SE->AddFd(this); + ServerInstance->SE->NonBlocking(this->fd); + ServerInstance->SE->AddFd(this, FD_WANT_POLL_READ | FD_WANT_NO_WRITE); } } } @@ -169,5 +169,5 @@ void ListenSocketBase::HandleEvent(EventType e, int err) void ClientListenSocket::OnAcceptReady(int nfd) { - ServerInstance->Users->AddUser(ServerInstance, nfd, this, &client, &server); + ServerInstance->Users->AddUser(nfd, this, &client, &server); }