Loading src/event/iocp.cpp +3 −4 Changes for src/event/iocp.cpp: 3 added lines, 4 removed lines. Original line number Diff line number Diff line Loading @@ -117,7 +117,7 @@ namespace netplus { g_eventapi->ConnectEvent(*pClientContext->CurCon, tid, args); buffer buf(BLOCKSIZE); buffer buf(nullptr, BLOCKSIZE); size_t ret=pClientContext->CurCon->csock->recvData(buf, 0); } private: Loading Loading @@ -240,7 +240,6 @@ namespace netplus { std::cerr << exp.what() << std::endl; } eargs->event->DisconnectEvent(*curCon, tid, args); closesocket(curCon->csock->fd()); delete pClientContext; continue; } Loading @@ -262,7 +261,7 @@ namespace netplus { } else { // Stay in read state and initiate another async read buffer buf(BLOCKSIZE); buffer buf(nullptr,BLOCKSIZE); curCon->csock->recvData(buf); } }break; Loading @@ -280,7 +279,7 @@ namespace netplus { else { // All data sent, switch to read state and initiate a new read pClientContext->State = IO_READ_STATE; buffer buf(BLOCKSIZE); buffer buf(nullptr, BLOCKSIZE); curCon->csock->recvData(buf); } }break; Loading src/windows/socket.cpp +3 Changes for src/windows/socket.cpp: 3 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -71,6 +71,9 @@ netplus::socket::~socket(){ WSACleanup(); } --_InitCount; delete[] _wsaBuf.buf; free((void*)_SocketInfo); } Loading src/windows/tcp.cpp +12 −8 Changes for src/windows/tcp.cpp: 12 added lines, 8 removed lines. Original line number Diff line number Diff line Loading @@ -228,18 +228,16 @@ size_t netplus::tcp::sendData(buffer &data,int flags){ size_t netplus::tcp::recvData(buffer &data,int flags){ NetException exception; if (data.ptr) { exception[NetException::Error] << "Socket recvdata error buffer with const ptr not supported!"; throw exception; } DWORD dwBytes = 0; memset(&_Overlapped, 0, sizeof(WSAOVERLAPPED)); _wsaBuf.buf = data.data.buf; _wsaBuf.len = static_cast<ULONG>(data.size); if (_wsaBuf.buf) delete[] _wsaBuf.buf; DWORD dwBytes = 0; _wsaBuf.buf = new char[data.size]; _wsaBuf.len = static_cast<ULONG>(data.size); int rval = ::WSARecv(_Socket, &_wsaBuf, 1, &dwBytes, (LPDWORD)&flags, &_Overlapped, nullptr); Loading @@ -258,6 +256,12 @@ size_t netplus::tcp::recvData(buffer &data,int flags){ } } if (data.ptr) { data.data.ptr = _wsaBuf.buf; }else{ std::copy(_wsaBuf.buf, _wsaBuf.buf + dwBytes, data.data.buf); } return (size_t)dwBytes; } Loading Loading
src/event/iocp.cpp +3 −4 Changes for src/event/iocp.cpp: 3 added lines, 4 removed lines. Original line number Diff line number Diff line Loading @@ -117,7 +117,7 @@ namespace netplus { g_eventapi->ConnectEvent(*pClientContext->CurCon, tid, args); buffer buf(BLOCKSIZE); buffer buf(nullptr, BLOCKSIZE); size_t ret=pClientContext->CurCon->csock->recvData(buf, 0); } private: Loading Loading @@ -240,7 +240,6 @@ namespace netplus { std::cerr << exp.what() << std::endl; } eargs->event->DisconnectEvent(*curCon, tid, args); closesocket(curCon->csock->fd()); delete pClientContext; continue; } Loading @@ -262,7 +261,7 @@ namespace netplus { } else { // Stay in read state and initiate another async read buffer buf(BLOCKSIZE); buffer buf(nullptr,BLOCKSIZE); curCon->csock->recvData(buf); } }break; Loading @@ -280,7 +279,7 @@ namespace netplus { else { // All data sent, switch to read state and initiate a new read pClientContext->State = IO_READ_STATE; buffer buf(BLOCKSIZE); buffer buf(nullptr, BLOCKSIZE); curCon->csock->recvData(buf); } }break; Loading
src/windows/socket.cpp +3 Changes for src/windows/socket.cpp: 3 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -71,6 +71,9 @@ netplus::socket::~socket(){ WSACleanup(); } --_InitCount; delete[] _wsaBuf.buf; free((void*)_SocketInfo); } Loading
src/windows/tcp.cpp +12 −8 Changes for src/windows/tcp.cpp: 12 added lines, 8 removed lines. Original line number Diff line number Diff line Loading @@ -228,18 +228,16 @@ size_t netplus::tcp::sendData(buffer &data,int flags){ size_t netplus::tcp::recvData(buffer &data,int flags){ NetException exception; if (data.ptr) { exception[NetException::Error] << "Socket recvdata error buffer with const ptr not supported!"; throw exception; } DWORD dwBytes = 0; memset(&_Overlapped, 0, sizeof(WSAOVERLAPPED)); _wsaBuf.buf = data.data.buf; _wsaBuf.len = static_cast<ULONG>(data.size); if (_wsaBuf.buf) delete[] _wsaBuf.buf; DWORD dwBytes = 0; _wsaBuf.buf = new char[data.size]; _wsaBuf.len = static_cast<ULONG>(data.size); int rval = ::WSARecv(_Socket, &_wsaBuf, 1, &dwBytes, (LPDWORD)&flags, &_Overlapped, nullptr); Loading @@ -258,6 +256,12 @@ size_t netplus::tcp::recvData(buffer &data,int flags){ } } if (data.ptr) { data.data.ptr = _wsaBuf.buf; }else{ std::copy(_wsaBuf.buf, _wsaBuf.buf + dwBytes, data.data.buf); } return (size_t)dwBytes; } Loading