Loading src/event/iocp.cpp +13 −17 Original line number Diff line number Diff line Loading @@ -399,26 +399,22 @@ namespace netplus { } // For SSL: need to handle handshake and decryption bool isSSL = (owner->csock->_Type == sockettype::SSL); bool isSSL = (owner->csock->getSocketType() == (int)sockettype::SSL); if (isSSL) { ssl* sslSock = static_cast<ssl*>(owner->csock.get()); // Feed raw bytes into SSL layer's receive buffer sslSock->_rx_tcp_buf.insert( sslSock->_rx_tcp_buf.end(), buf->data.buf, buf->data.buf + bytes ); // Create buffer with received raw bytes for SSL processing buffer rawBuf(buf->data.buf, bytes); // Check if handshake is done if (!sslSock->getHandshakeDone()) { if (!owner->csock->getHandshakeDone()) { try { sslSock->handshake_after_accept(); // recvData for SSL will process raw bytes from buffer owner->csock->recvData(rawBuf, 0); owner->csock->handshake_after_accept(); // If there's pending data to send (handshake response) if (sslSock->hasPendingWrite()) { sslSock->flush_out(); if (owner->csock->hasPendingWrite()) { owner->csock->flush_out(); } } catch (NetException& e) { if (e.getErrorType() == NetException::Note) { Loading @@ -436,7 +432,7 @@ namespace netplus { } // If handshake still not done, wait for more data if (!sslSock->getHandshakeDone()) { if (!owner->csock->getHandshakeDone()) { try { post_recv(st, *owner); } catch (...) {} Loading @@ -446,8 +442,8 @@ namespace netplus { // Handshake done - try to decrypt application data try { buffer decrypted(BLOCKSIZE); size_t decLen = sslSock->recvData(decrypted, 0); buffer decrypted(buf->data.buf, bytes); size_t decLen = owner->csock->recvData(decrypted, 0); if (decLen > 0) { owner->RecvData.append(decrypted.data.buf, decLen); Loading Loading @@ -491,7 +487,7 @@ namespace netplus { else if (buf->operation == OP_WRITE) { // For SSL, the send encrypts all pending data at once // So we clear SendData entirely on completion if (owner->csock->getSocketType() == sockettype::SSL) { if (owner->csock->getSocketType() == (int)sockettype::SSL) { // SSL: all data was encrypted and sent owner->SendData.clear(); owner->SendOff = 0; Loading src/socket.h +1 −0 Original line number Diff line number Diff line Loading @@ -180,6 +180,7 @@ namespace netplus { virtual bool hasPendingWrite() const { return false; } virtual bool getHandshakeDone() { return true; } virtual int getSocketType() const { return _Type; } virtual void connect(const std::string& addr, int port, bool nonblock = false) = 0; virtual void getAddress(std::string& addr) = 0; Loading Loading
src/event/iocp.cpp +13 −17 Original line number Diff line number Diff line Loading @@ -399,26 +399,22 @@ namespace netplus { } // For SSL: need to handle handshake and decryption bool isSSL = (owner->csock->_Type == sockettype::SSL); bool isSSL = (owner->csock->getSocketType() == (int)sockettype::SSL); if (isSSL) { ssl* sslSock = static_cast<ssl*>(owner->csock.get()); // Feed raw bytes into SSL layer's receive buffer sslSock->_rx_tcp_buf.insert( sslSock->_rx_tcp_buf.end(), buf->data.buf, buf->data.buf + bytes ); // Create buffer with received raw bytes for SSL processing buffer rawBuf(buf->data.buf, bytes); // Check if handshake is done if (!sslSock->getHandshakeDone()) { if (!owner->csock->getHandshakeDone()) { try { sslSock->handshake_after_accept(); // recvData for SSL will process raw bytes from buffer owner->csock->recvData(rawBuf, 0); owner->csock->handshake_after_accept(); // If there's pending data to send (handshake response) if (sslSock->hasPendingWrite()) { sslSock->flush_out(); if (owner->csock->hasPendingWrite()) { owner->csock->flush_out(); } } catch (NetException& e) { if (e.getErrorType() == NetException::Note) { Loading @@ -436,7 +432,7 @@ namespace netplus { } // If handshake still not done, wait for more data if (!sslSock->getHandshakeDone()) { if (!owner->csock->getHandshakeDone()) { try { post_recv(st, *owner); } catch (...) {} Loading @@ -446,8 +442,8 @@ namespace netplus { // Handshake done - try to decrypt application data try { buffer decrypted(BLOCKSIZE); size_t decLen = sslSock->recvData(decrypted, 0); buffer decrypted(buf->data.buf, bytes); size_t decLen = owner->csock->recvData(decrypted, 0); if (decLen > 0) { owner->RecvData.append(decrypted.data.buf, decLen); Loading Loading @@ -491,7 +487,7 @@ namespace netplus { else if (buf->operation == OP_WRITE) { // For SSL, the send encrypts all pending data at once // So we clear SendData entirely on completion if (owner->csock->getSocketType() == sockettype::SSL) { if (owner->csock->getSocketType() == (int)sockettype::SSL) { // SSL: all data was encrypted and sent owner->SendData.clear(); owner->SendOff = 0; Loading
src/socket.h +1 −0 Original line number Diff line number Diff line Loading @@ -180,6 +180,7 @@ namespace netplus { virtual bool hasPendingWrite() const { return false; } virtual bool getHandshakeDone() { return true; } virtual int getSocketType() const { return _Type; } virtual void connect(const std::string& addr, int port, bool nonblock = false) = 0; virtual void getAddress(std::string& addr) = 0; Loading