diff options
-rw-r--r-- | data/commands.example.conf | 2 | ||||
-rw-r--r-- | data/example.conf | 6 | ||||
-rw-r--r-- | include/sockets.h | 29 | ||||
-rw-r--r-- | modules/core/cs_register.cpp | 2 | ||||
-rw-r--r-- | modules/core/cs_saset_noexpire.cpp | 2 | ||||
-rw-r--r-- | modules/extra/m_ssl.cpp | 141 | ||||
-rw-r--r-- | modules/extra/os_defcon.cpp | 6 | ||||
-rw-r--r-- | src/config.cpp | 14 | ||||
-rw-r--r-- | src/sockets.cpp | 109 |
9 files changed, 227 insertions, 84 deletions
diff --git a/data/commands.example.conf b/data/commands.example.conf index 20a65ec66..4385ae6de 100644 --- a/data/commands.example.conf +++ b/data/commands.example.conf @@ -131,7 +131,7 @@ module { name = "cs_set_xop" } command { service = "ChanServ"; name = "SET XOP"; command = "chanserv/set/xop"; } command { service = "ChanServ"; name = "SASET XOP"; command = "chanserv/saset/xop"; } module { name = "cs_saset_noexpire" } -command { service = "ChanServ"; name = "SET NOEXPIRE"; command = "chanserv/set/noexpire"; } +command { service = "ChanServ"; name = "SASET NOEXPIRE"; command = "chanserv/saset/noexpire"; } module { name = "cs_status" } command { service = "ChanServ"; name = "STATUS"; command = "chanserv/status"; } module { name = "cs_suspend" } diff --git a/data/example.conf b/data/example.conf index cd6f0570d..e5820f60c 100644 --- a/data/example.conf +++ b/data/example.conf @@ -538,7 +538,7 @@ botserv * The name of the client that should be BotServ. * Clients are configured above. */ - nick = "BotServ" + name = "BotServ" /* * The default bot options for newly registered channels. Note that changing these options @@ -1315,7 +1315,7 @@ log * chanserv/saset/peace chanserv/saset/persist chanserv/saset/private * chanserv/saset/secure chanserv/saset/securefounder chanserv/saset/secureops * chanserv/saset/signkick chanserv/saset/successor chanserv/saset/topiclock - * chanserv/saset/url chanserv/saset/xop + * chanserv/saset/url chanserv/saset/xop chanserv/saset/noexpire * * memoserv/sendall memoserv/staff * @@ -1377,7 +1377,7 @@ opertype inherits = "Services Operator" - commands = "chanserv/access/list chanserv/drop chanserv/forbid chanserv/getkey chanserv/set/noexpire memoserv/sendall nickserv/saset/* nickserv/getemail operserv/news operserv/jupe operserv/svsnick operserv/stats operserv/oline operserv/noop global/*" + commands = "chanserv/access/list chanserv/drop chanserv/forbid chanserv/getkey chanserv/saset/noexpire memoserv/sendall nickserv/saset/* nickserv/getemail operserv/news operserv/jupe operserv/svsnick operserv/stats operserv/oline operserv/noop global/*" privs = "*" } diff --git a/include/sockets.h b/include/sockets.h index 5e5ca1fde..eb86130b5 100644 --- a/include/sockets.h +++ b/include/sockets.h @@ -152,6 +152,12 @@ class CoreExport SocketIO */ virtual ClientSocket *Accept(ListenSocket *s); + /** Check if a connection has been accepted + * @param s The client socket + * @return -1 on error, 0 to wait, 1 on success + */ + virtual int Accepted(ClientSocket *cs); + /** Bind a socket * @param s The socket * @param ip The IP to bind to @@ -160,12 +166,18 @@ class CoreExport SocketIO virtual void Bind(Socket *s, const Anope::string &ip, int port = 0); /** Connect the socket - * @param s THe socket + * @param s The socket * @param target IP to connect to * @param port to connect to */ virtual void Connect(ConnectionSocket *s, const Anope::string &target, int port); + /** Check if this socket is connected + * @param s The socket + * @return -1 for error, 0 for wait, 1 for connected + */ + virtual int Connected(ConnectionSocket *s); + /** Called when the socket is destructing */ virtual void Destroy() { } @@ -352,6 +364,11 @@ class CoreExport ConnectionSocket : public BufferedSocket */ void Connect(const Anope::string &TargetHost, int Port); + /** Called when there is something to be received for this socket + * @return true on success, false to drop this socket + */ + bool ProcessRead(); + /** Called when the socket is ready to be written to * @return true on success, false to drop this socket */ @@ -386,6 +403,16 @@ class CoreExport ClientSocket : public BufferedSocket * @param addr Address the connection came from */ ClientSocket(ListenSocket *ls, int fd, const sockaddrs &addr); + + /** Called when there is something to be received for this socket + * @return true on success, false to drop this socket + */ + bool ProcessRead(); + + /** Called when the socket is ready to be written to + * @return true on success, false to drop this socket + */ + bool ProcessWrite(); }; class CoreExport Pipe : public BufferedSocket diff --git a/modules/core/cs_register.cpp b/modules/core/cs_register.cpp index 7f08828fc..117212519 100644 --- a/modules/core/cs_register.cpp +++ b/modules/core/cs_register.cpp @@ -143,7 +143,7 @@ class ExpireCallback : public CallBack if (Config->CSSuspendExpire && Anope::CurTime - ci->last_used >= Config->CSSuspendExpire) expire = true; } - else if (!ci->c && Anope::CurTime - ci->last_used >= Config->CSExpire) + else if (!ci->c && Config->CSExpire && Anope::CurTime - ci->last_used >= Config->CSExpire) expire = true; if (ci->HasFlag(CI_NO_EXPIRE)) diff --git a/modules/core/cs_saset_noexpire.cpp b/modules/core/cs_saset_noexpire.cpp index 414b822a7..fa944f86a 100644 --- a/modules/core/cs_saset_noexpire.cpp +++ b/modules/core/cs_saset_noexpire.cpp @@ -19,7 +19,7 @@ class CommandCSSASetNoexpire : public Command CommandCSSASetNoexpire(Module *creator) : Command(creator, "chanserv/saset/noexpire", 2, 2, "chanserv/saset/noexpire") { this->SetDesc(_("Prevent the channel from expiring")); - this->SetDesc(_("\037channel\037 NOEXPIRE {ON | OFF}")); + this->SetDesc(_("\037channel\037 {ON | OFF}")); } void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) diff --git a/modules/extra/m_ssl.cpp b/modules/extra/m_ssl.cpp index 30e548150..eb723a341 100644 --- a/modules/extra/m_ssl.cpp +++ b/modules/extra/m_ssl.cpp @@ -28,11 +28,6 @@ class MySSLService : public SSLService class SSLSocketIO : public SocketIO { - /** Check whether this socket has a pending connect() or accept() - * @return 0 if neither, -1 if connect/accept fails, -2 to wait more - */ - int CheckState(); - public: /* The SSL socket for this socket */ SSL *sslsock; @@ -64,6 +59,12 @@ class SSLSocketIO : public SocketIO */ ClientSocket *Accept(ListenSocket *s); + /** Check if a connection has been accepted + * @param s The client socket + * @return -1 on error, 0 to wait, 1 on success + */ + int Accepted(ClientSocket *cs); + /** Connect the socket * @param s THe socket * @param target IP to connect to @@ -71,6 +72,12 @@ class SSLSocketIO : public SocketIO */ void Connect(ConnectionSocket *s, const Anope::string &target, int port); + /** Check if this socket is connected + * @param s The socket + * @return -1 for error, 0 for wait, 1 for connected + */ + int Connected(ConnectionSocket *s); + /** Called when the socket is destructing */ void Destroy(); @@ -187,34 +194,6 @@ void MySSLService::Init(Socket *s) s->IO = new SSLSocketIO(); } -int SSLSocketIO::CheckState() -{ - if (this->connected == 0 || this->accepted == 0) - { - int ret; - if (this->connected == 0) - ret = SSL_connect(this->sslsock); - else if (this->accepted == 0) - ret = SSL_accept(this->sslsock); - if (ret <= 0) - { - int error = SSL_get_error(this->sslsock, ret); - - if (ret == -1 && (error == SSL_ERROR_WANT_READ || error == SSL_ERROR_WANT_WRITE)) - // Wait more - return -2; - return -1; - } - - if (this->connected == 0) - this->connected = 1; - else if (this->accepted == 0) - this->accepted = 1; - } - - return 0; -} - SSLSocketIO::SSLSocketIO() : connected(-1), accepted(-1) { this->sslsock = NULL; @@ -222,22 +201,14 @@ SSLSocketIO::SSLSocketIO() : connected(-1), accepted(-1) int SSLSocketIO::Recv(Socket *s, char *buf, size_t sz) { - int i = this->CheckState(); - if (i < 0) - return i; - - i = SSL_read(this->sslsock, buf, sz); + int i = SSL_read(this->sslsock, buf, sz); TotalRead += i; return i; } int SSLSocketIO::Send(Socket *s, const Anope::string &buf) { - int i = this->CheckState(); - if (i < 0) - return i; - - i = SSL_write(this->sslsock, buf.c_str(), buf.length()); + int i = SSL_write(this->sslsock, buf.c_str(), buf.length()); TotalWritten += i; return i; } @@ -260,13 +231,49 @@ ClientSocket *SSLSocketIO::Accept(ListenSocket *s) if (!SSL_set_fd(IO->sslsock, newsocket->GetFD())) throw SocketException("Unable to set SSL fd"); - IO->accepted = 0; - if (this->CheckState() == -1) + int ret = SSL_accept(IO->sslsock); + if (ret <= 0) + { + IO->accepted = 0; + int error = SSL_get_error(IO->sslsock, ret); + if (ret == -1 && (error == SSL_ERROR_WANT_READ || error == SSL_ERROR_WANT_WRITE)) + { + SocketEngine::MarkWritable(newsocket); + return newsocket; + } + throw SocketException("Unable to accept new SSL connection: " + Anope::string(ERR_error_string(ERR_get_error(), NULL))); + } + IO->accepted = 1; return newsocket; } +int SSLSocketIO::Accepted(ClientSocket *cs) +{ + SSLSocketIO *IO = debug_cast<SSLSocketIO *>(cs->IO); + + if (IO->accepted == 0) + { + int ret = SSL_accept(IO->sslsock); + if (ret <= 0) + { + int error = SSL_get_error(IO->sslsock, ret); + if (ret == -1 && (error == SSL_ERROR_WANT_READ || error == SSL_ERROR_WANT_WRITE)) + { + SocketEngine::MarkWritable(cs); + return 0; + } + + return -1; + } + IO->accepted = 1; + return 0; + } + + return IO->accepted; +} + void SSLSocketIO::Connect(ConnectionSocket *s, const Anope::string &target, int port) { if (s->IO == &normalSocketIO) @@ -283,9 +290,49 @@ void SSLSocketIO::Connect(ConnectionSocket *s, const Anope::string &target, int if (!SSL_set_fd(IO->sslsock, s->GetFD())) throw SocketException("Unable to set SSL fd"); - IO->connected = 0; - if (this->CheckState() == -1) + int ret = SSL_connect(IO->sslsock); + if (ret <= 0) + { + IO->connected = 0; + int error = SSL_get_error(IO->sslsock, ret); + if (ret == -1 && (error == SSL_ERROR_WANT_READ || error == SSL_ERROR_WANT_WRITE)) + { + SocketEngine::MarkWritable(s); + return; + } + throw SocketException("Unable to connect to server: " + Anope::string(ERR_error_string(ERR_get_error(), NULL))); + } + + IO->connected = 1; +} + +int SSLSocketIO::Connected(ConnectionSocket *s) +{ + if (s->IO == &normalSocketIO) + throw SocketException("Connected() called for non ssl socket?"); + + int i = SocketIO::Connected(s); + if (i != 1) + return i; + + SSLSocketIO *IO = debug_cast<SSLSocketIO *>(s->IO); + + if (IO->connected == 0) + { + int ret = SSL_connect(IO->sslsock); + if (ret <= 0) + { + int error = SSL_get_error(IO->sslsock, ret); + if (ret == -1 && (error == SSL_ERROR_WANT_READ || error == SSL_ERROR_WANT_WRITE)) + return 0; + return -1; + } + IO->connected = 1; + return 0; // poll for next read/write (which will be real), don't assume ones available + } + + return IO->connected; } void SSLSocketIO::Destroy() diff --git a/modules/extra/os_defcon.cpp b/modules/extra/os_defcon.cpp index cad01e8a4..9cfe66e09 100644 --- a/modules/extra/os_defcon.cpp +++ b/modules/extra/os_defcon.cpp @@ -336,9 +336,6 @@ class OSDefcon : public Module public: OSDefcon(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, SUPPORTED), session_service("session"), akills("xlinemanager/sgline"), commandosdefcon(this) { - if (!DConfig.defaultlevel) - throw ModuleException("Invalid configuration settings"); - this->SetAuthor("Anope"); Implementation i[] = { I_OnReload, I_OnChannelModeSet, I_OnChannelModeUnset, I_OnPreCommand, I_OnUserConnect, I_OnChannelModeAdd, I_OnChannelCreate }; @@ -347,6 +344,9 @@ class OSDefcon : public Module ModuleManager::RegisterService(&commandosdefcon); this->OnReload(); + + if (!DConfig.defaultlevel) + throw ModuleException("Invalid configuration settings"); } void OnReload() diff --git a/src/config.cpp b/src/config.cpp index 0d9341424..5938d3f67 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -1108,7 +1108,7 @@ ConfigItems::ConfigItems(ServerConfig *conf) {"options", "botmodes", "", new ValueContainerString(&conf->BotModes), DT_STRING, NoValidation}, {"options", "retrywait", "60", new ValueContainerInt(&conf->RetryWait), DT_INTEGER, ValidateNotZero}, {"options", "hideprivilegedcommands", "no", new ValueContainerBool(&conf->HidePrivilegedCommands), DT_BOOLEAN, NoValidation}, - {"nickserv", "name", "NickServ", new ValueContainerString(&conf->NickServ), DT_STRING, NoValidation}, + {"nickserv", "name", "", new ValueContainerString(&conf->NickServ), DT_STRING, NoValidation}, {"nickserv", "emailregistration", "no", new ValueContainerBool(&conf->NSEmailReg), DT_BOOLEAN, NoValidation}, {"nickserv", "forceemail", "no", new ValueContainerBool(&conf->NSForceEmail), DT_BOOLEAN, ValidateEmailReg}, {"nickserv", "confirmemailchanges", "no", new ValueContainerBool(&conf->NSConfirmEmailChanges), DT_BOOLEAN, NoValidation}, @@ -1143,7 +1143,7 @@ ConfigItems::ConfigItems(ServerConfig *conf) {"mail", "dontquoteaddresses", "no", new ValueContainerBool(&conf->DontQuoteAddresses), DT_BOOLEAN, NoValidation}, {"dns", "nameserver", "127.0.0.1", new ValueContainerString(&conf->NameServer), DT_STRING, NoValidation}, {"dns", "timeout", "5", new ValueContainerTime(&conf->DNSTimeout), DT_TIME, NoValidation}, - {"chanserv", "name", "ChanServ", new ValueContainerString(&conf->ChanServ), DT_STRING, NoValidation}, + {"chanserv", "name", "", new ValueContainerString(&conf->ChanServ), DT_STRING, NoValidation}, {"chanserv", "defaults", "keeptopic secure securefounder signkick", new ValueContainerString(&CSDefaults), DT_STRING, ValidateChanServ}, {"chanserv", "maxregistered", "0", new ValueContainerUInt(&conf->CSMaxReg), DT_UINTEGER, ValidateChanServ}, {"chanserv", "expire", "14d", new ValueContainerTime(&conf->CSExpire), DT_TIME, ValidateChanServ}, @@ -1157,13 +1157,13 @@ ConfigItems::ConfigItems(ServerConfig *conf) {"chanserv", "listopersonly", "no", new ValueContainerBool(&conf->CSListOpersOnly), DT_BOOLEAN, ValidateChanServ}, {"chanserv", "listmax", "0", new ValueContainerUInt(&conf->CSListMax), DT_UINTEGER, ValidateChanServ}, {"chanserv", "opersonly", "no", new ValueContainerBool(&conf->CSOpersOnly), DT_BOOLEAN, ValidateChanServ}, - {"memoserv", "name", "MemoServ", new ValueContainerString(&conf->MemoServ), DT_STRING, NoValidation}, + {"memoserv", "name", "", new ValueContainerString(&conf->MemoServ), DT_STRING, NoValidation}, {"memoserv", "maxmemos", "0", new ValueContainerUInt(&conf->MSMaxMemos), DT_UINTEGER, NoValidation}, {"memoserv", "senddelay", "0", new ValueContainerTime(&conf->MSSendDelay), DT_TIME, NoValidation}, {"memoserv", "notifyall", "no", new ValueContainerBool(&conf->MSNotifyAll), DT_BOOLEAN, NoValidation}, {"memoserv", "memoreceipt", "0", new ValueContainerUInt(&conf->MSMemoReceipt), DT_UINTEGER, NoValidation}, - {"hostserv", "name", "HostServ", new ValueContainerString(&conf->HostServ), DT_STRING, NoValidation}, - {"botserv", "name", "BotServ", new ValueContainerString(&conf->BotServ), DT_STRING, NoValidation}, + {"hostserv", "name", "", new ValueContainerString(&conf->HostServ), DT_STRING, NoValidation}, + {"botserv", "name", "", new ValueContainerString(&conf->BotServ), DT_STRING, NoValidation}, {"botserv", "defaults", "", new ValueContainerString(&BSDefaults), DT_STRING, NoValidation}, {"botserv", "minusers", "0", new ValueContainerUInt(&conf->BSMinUsers), DT_UINTEGER, ValidateBotServ}, {"botserv", "badwordsmax", "0", new ValueContainerUInt(&conf->BSBadWordsMax), DT_UINTEGER, ValidateBotServ}, @@ -1172,7 +1172,7 @@ ConfigItems::ConfigItems(ServerConfig *conf) {"botserv", "gentlebadwordreason", "no", new ValueContainerBool(&conf->BSGentleBWReason), DT_BOOLEAN, NoValidation}, {"botserv", "casesensitive", "no", new ValueContainerBool(&conf->BSCaseSensitive), DT_BOOLEAN, NoValidation}, {"botserv", "fantasycharacter", "!", new ValueContainerString(&conf->BSFantasyCharacter), DT_STRING, NoValidation}, - {"operserv", "name", "OperServ", new ValueContainerString(&conf->OperServ), DT_STRING, NoValidation}, + {"operserv", "name", "", new ValueContainerString(&conf->OperServ), DT_STRING, NoValidation}, {"operserv", "superadmin", "no", new ValueContainerBool(&conf->SuperAdmin), DT_BOOLEAN, NoValidation}, {"operserv", "autokillexpiry", "0", new ValueContainerTime(&conf->AutokillExpiry), DT_TIME, ValidateOperServ}, {"operserv", "chankillexpiry", "0", new ValueContainerTime(&conf->ChankillExpiry), DT_TIME, ValidateOperServ}, @@ -1193,7 +1193,7 @@ ConfigItems::ConfigItems(ServerConfig *conf) {"operserv", "sessionautokillexpiry", "0", new ValueContainerTime(&conf->SessionAutoKillExpiry), DT_TIME, NoValidation}, {"operserv", "addakiller", "no", new ValueContainerBool(&conf->AddAkiller), DT_BOOLEAN, NoValidation}, {"operserv", "opersonly", "no", new ValueContainerBool(&conf->OSOpersOnly), DT_BOOLEAN, NoValidation}, - {"global", "name", "Global", new ValueContainerString(&conf->Global), DT_STRING, NoValidation}, + {"global", "name", "", new ValueContainerString(&conf->Global), DT_STRING, NoValidation}, {"global", "globaloncycle", "no", new ValueContainerBool(&conf->GlobalOnCycle), DT_BOOLEAN, NoValidation}, {"global", "globaloncycledown", "", new ValueContainerString(&conf->GlobalOnCycleMessage), DT_STRING, ValidateGlobalOnCycle}, {"global", "globaloncycleup", "", new ValueContainerString(&conf->GlobalOnCycleUP), DT_STRING, ValidateGlobalOnCycle}, diff --git a/src/sockets.cpp b/src/sockets.cpp index 7765d3066..122d6b646 100644 --- a/src/sockets.cpp +++ b/src/sockets.cpp @@ -291,6 +291,15 @@ ClientSocket *SocketIO::Accept(ListenSocket *s) throw SocketException("Unable to accept connection: " + Anope::LastError()); } +/** Check if a connection has been accepted + * @param s The client socket + * @return -1 on error, 0 to wait, 1 on success + */ +int SocketIO::Accepted(ClientSocket *cs) +{ + return 1; +} + /** Bind a socket * @param s The socket * @param ip The IP to bind to @@ -321,11 +330,20 @@ void SocketIO::Connect(ConnectionSocket *s, const Anope::string &target, int por } else { - s->OnConnect(); s->connected = true; + s->OnConnect(); } } +/** Check if this socket is connected + * @param s The socket + * @return -1 for error, 0 for wait, 1 for connected + */ +int SocketIO::Connected(ConnectionSocket *s) +{ + return s->connected == true ? 1 : -1; +} + /** Empty constructor, used for things such as the pipe socket */ Socket::Socket() : Flags<SocketFlag, 2>(SocketFlagStrings) @@ -465,16 +483,15 @@ BufferedSocket::~BufferedSocket() */ bool BufferedSocket::ProcessRead() { - char tbuffer[NET_BUFSIZE] = ""; + char tbuffer[NET_BUFSIZE]; this->RecvLen = 0; int len = this->IO->Recv(this, tbuffer, sizeof(tbuffer) - 1); - if (len == -2) - return true; - else if (len <= 0) + if (len <= 0) return false; + tbuffer[len] = 0; this->RecvLen = len; Anope::string sbuffer = this->extrabuf; @@ -512,9 +529,7 @@ bool BufferedSocket::ProcessRead() bool BufferedSocket::ProcessWrite() { int count = this->IO->Send(this, this->WriteBuffer); - if (count == -2) - return true; - else if (count <= -1) + if (count <= -1) return false; this->WriteBuffer = this->WriteBuffer.substr(count); if (this->WriteBuffer.empty()) @@ -589,7 +604,7 @@ ListenSocket::ListenSocket(const Anope::string &bindip, int port, bool ipv6) : S this->bindaddr.pton(IPv6 ? AF_INET6 : AF_INET, bindip, port); this->IO->Bind(this, bindip, port); - if (listen(Sock, 5) == -1) + if (listen(Sock, SOMAXCONN) == -1) throw SocketException(Anope::string("Unable to listen: ") + Anope::LastError()); } @@ -642,6 +657,34 @@ void ConnectionSocket::Connect(const Anope::string &TargetHost, int Port) this->IO->Connect(this, TargetHost, Port); } +/** Called when there is something to be received for this socket + * @return true on success, false to drop this socket + */ +bool ConnectionSocket::ProcessRead() +{ + if (!this->connected) + { + int optval = 0; + socklen_t optlen = sizeof(optval); + if (!getsockopt(this->GetFD(), SOL_SOCKET, SO_ERROR, &optval, &optlen) && !optval) + { + this->connected = true; + this->OnConnect(); + } + else + errno = optval; + } + + int i = this->IO->Connected(this); + if (i == 1) + return BufferedSocket::ProcessRead(); + else if (i == 0) + return true; + + this->OnError(Anope::LastError()); + return false; +} + /** Called when the socket is ready to be written to * @return true on success, false to drop this socket */ @@ -649,23 +692,25 @@ bool ConnectionSocket::ProcessWrite() { if (!this->connected) { - SocketEngine::ClearWritable(this); - int optval = 0; socklen_t optlen = sizeof(optval); if (!getsockopt(this->GetFD(), SOL_SOCKET, SO_ERROR, &optval, &optlen) && !optval) { - this->OnConnect(); this->connected = true; - return true; + this->OnConnect(); } - - errno = optval; - this->OnError(Anope::LastError()); - return false; + else + errno = optval; } - return BufferedSocket::ProcessWrite(); + int i = this->IO->Connected(this); + if (i == 1) + return BufferedSocket::ProcessWrite(); + else if (i == 0) + return true; + + this->OnError(Anope::LastError()); + return false; } /** Called when there is an error for this socket @@ -673,8 +718,6 @@ bool ConnectionSocket::ProcessWrite() */ void ConnectionSocket::ProcessError() { - if (!this->connected) - this->ProcessWrite(); } /** Called on a successful connect @@ -700,3 +743,29 @@ ClientSocket::ClientSocket(ListenSocket *ls, int fd, const sockaddrs &addr) : Bu this->Type = SOCKTYPE_CLIENT; } +/** Called when there is something to be received for this socket + * @return true on success, false to drop this socket + */ +bool ClientSocket::ProcessRead() +{ + int i = this->IO->Accepted(this); + if (i == 1) + return BufferedSocket::ProcessRead(); + else if (i == 0) + return true; + return false; +} + +/** Called when the socket is ready to be written to + * @return true on success, false to drop this socket + */ +bool ClientSocket::ProcessWrite() +{ + int i = this->IO->Accepted(this); + if (i == 1) + return BufferedSocket::ProcessWrite(); + else if (i == 0) + return true; + return false; +} + |