Commit 1d46037f authored by jan.koester's avatar jan.koester
Browse files

test

parent 86fa3798
Loading
Loading
Loading
Loading
+3 −4
Changes for src/event/iocp.cpp: 3 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -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:
@@ -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;
				}
@@ -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;
@@ -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;
+3
Changes for src/windows/socket.cpp: 3 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -71,6 +71,9 @@ netplus::socket::~socket(){
        WSACleanup();
    }
    --_InitCount;

	delete[] _wsaBuf.buf;

    free((void*)_SocketInfo);
}

+12 −8
Changes for src/windows/tcp.cpp: 12 added lines, 8 removed lines.
Original line number Diff line number Diff line
@@ -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);

@@ -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;
}