Loading src/event/iocp.cpp −18 Changes for src/event/iocp.cpp: 0 added lines, 18 removed lines. Original line number Diff line number Diff line Loading @@ -273,16 +273,7 @@ namespace netplus { buffer buf(curCon->SendData.data(),ssize); try{ ret = curCon->csock->sendData(buf, 0); } catch (NetException& e) { if (e.getErrorType() == NetException::Note) { continue; // Retry sending data } else { throw e; // Rethrow other exceptions } } // Erase the sent data from the beginning of the buffer curCon->SendData.resize(ret); Loading @@ -298,16 +289,7 @@ namespace netplus { size_t recv = 0; try { recv = curCon->csock->recvData(buf, 0); } catch (NetException& e) { if (e.getErrorType() == NetException::Note) { std::cout << "Note: " << e.what() << std::endl; continue; // Retry receiving data } else { throw e; // Rethrow other exceptions } } curCon->RecvData.append(buf.data.buf, recv); Loading src/windows/tcp.cpp +4 −4 Changes for src/windows/tcp.cpp: 4 added lines, 4 removed lines. Original line number Diff line number Diff line Loading @@ -212,9 +212,9 @@ size_t netplus::tcp::sendData(buffer &data,int flags){ if(rval == SOCKET_ERROR){ switch(WSAGetLastError()){ case WSAEWOULDBLOCK: throw exception[NetException::Note] << "Socket senddata failed WSAWOULDBLOCK on Socket: " << (int)_Socket; return (size_t)dwsend; case WSA_IO_PENDING: throw exception[NetException::Note] << "Socket senddata failed WSA_IO_PENDING on Socket: " << (int)_Socket; return (size_t)dwsend; case WSAENOTCONN: throw exception[NetException::Error] << "Socket senddata failed WSAENOTCONN on Socket: " << (int)_Socket; case WSAECONNRESET: Loading Loading @@ -246,9 +246,9 @@ size_t netplus::tcp::recvData(buffer &data,int flags){ if (rval == SOCKET_ERROR) { switch (WSAGetLastError()) { case WSAEWOULDBLOCK: throw exception[NetException::Note] << "Socket recvData failed WSAWOULDBLOCK on Socket: " << (int)_Socket; return (size_t)dwBytes; case WSA_IO_PENDING: throw exception[NetException::Note] << "Socket recvData failed WSA_IO_PENDING on Socket: " << (int)_Socket; return (size_t)dwBytes; case WSAENOTCONN: throw exception[NetException::Error] << "Socket recvData failed WSAENOTCONN on Socket: " << (int)_Socket; case WSAECONNRESET: Loading src/windows/udp.cpp +33 −26 Changes for src/windows/udp.cpp: 33 added lines, 26 removed lines. Original line number Diff line number Diff line Loading @@ -189,9 +189,7 @@ void netplus::udp::bind() { } size_t netplus::udp::sendData(buffer &data, int flags) { NetException exception; WSABUF buf; WSABUF buf{ 0 }; if (data.ptr) buf.buf = (char*)data.data.ptr; Loading @@ -200,25 +198,30 @@ size_t netplus::udp::sendData(buffer &data, int flags) { buf.len = static_cast<ULONG>(data.size); DWORD dwBytes = 0; DWORD dwFlags = 0; DWORD dwsend = 0; SOCKET rval = ::WSASend(_Socket, &buf, 1, &dwBytes, flags, &_Overlapped, nullptr); int rval = ::WSASend(_Socket, &buf, 1, &dwsend, flags, &_Overlapped, nullptr); if (rval == SOCKET_ERROR) { int etype = NetException::Error; if (GetLastError() == WSA_IO_PENDING) etype = NetException::Note; NetException exception; exception[etype] << "Socket senddata failed on Socket: " << (int)_Socket << " ErrorMsg: " << GetLastError(); throw exception; if (rval == SOCKET_ERROR) { switch (WSAGetLastError()) { case WSAEWOULDBLOCK: return (size_t)dwsend; case WSA_IO_PENDING: return (size_t)dwsend; case WSAENOTCONN: throw exception[NetException::Error] << "Socket senddata failed WSAENOTCONN on Socket: " << (int)_Socket; case WSAECONNRESET: throw exception[NetException::Error] << "Socket senddata failed WSAECONNRESET on Socket: " << (int)_Socket; default: throw exception[NetException::Error] << "Socket senddata failed some Error on Socket: " << (int)_Socket; } return (size_t)dwBytes; } return (size_t)dwsend; } size_t netplus::udp::recvData(buffer &data, int flags) { NetException exception; if (data.ptr) { Loading @@ -232,20 +235,24 @@ size_t netplus::udp::recvData(buffer &data, int flags) { buf.len = static_cast<ULONG>(data.size); DWORD dwBytes = 0; DWORD dwFlags = 0; int recvsize = ::WSARecv(_Socket, &buf, 1, &dwBytes, (LPDWORD)&flags, &_Overlapped, nullptr); if (recvsize < 0) { int etype = NetException::Error; if (GetLastError() == EAGAIN) etype = NetException::Note; int rval = ::WSARecv(_Socket, &buf, 1, &dwBytes, (LPDWORD)&flags, &_Overlapped, nullptr); exception[etype] << "Socket recvdata failed on Socket: " << (int)_Socket << " ErrorMsg: " << GetLastError(); throw exception; if (rval == SOCKET_ERROR) { switch (WSAGetLastError()) { case WSAEWOULDBLOCK: return (size_t)dwBytes; case WSA_IO_PENDING: return (size_t)dwBytes; case WSAENOTCONN: throw exception[NetException::Error] << "Socket recvData failed WSAENOTCONN on Socket: " << (int)_Socket; case WSAECONNRESET: throw exception[NetException::Error] << "Socket recvData failed WSAECONNRESET on Socket: " << (int)_Socket; default: throw exception[NetException::Error] << "Socket recvData failed some Error on Socket: " << (int)_Socket; } } return (size_t)dwBytes; } void netplus::udp::connect(socket* ssock) { Loading Loading
src/event/iocp.cpp −18 Changes for src/event/iocp.cpp: 0 added lines, 18 removed lines. Original line number Diff line number Diff line Loading @@ -273,16 +273,7 @@ namespace netplus { buffer buf(curCon->SendData.data(),ssize); try{ ret = curCon->csock->sendData(buf, 0); } catch (NetException& e) { if (e.getErrorType() == NetException::Note) { continue; // Retry sending data } else { throw e; // Rethrow other exceptions } } // Erase the sent data from the beginning of the buffer curCon->SendData.resize(ret); Loading @@ -298,16 +289,7 @@ namespace netplus { size_t recv = 0; try { recv = curCon->csock->recvData(buf, 0); } catch (NetException& e) { if (e.getErrorType() == NetException::Note) { std::cout << "Note: " << e.what() << std::endl; continue; // Retry receiving data } else { throw e; // Rethrow other exceptions } } curCon->RecvData.append(buf.data.buf, recv); Loading
src/windows/tcp.cpp +4 −4 Changes for src/windows/tcp.cpp: 4 added lines, 4 removed lines. Original line number Diff line number Diff line Loading @@ -212,9 +212,9 @@ size_t netplus::tcp::sendData(buffer &data,int flags){ if(rval == SOCKET_ERROR){ switch(WSAGetLastError()){ case WSAEWOULDBLOCK: throw exception[NetException::Note] << "Socket senddata failed WSAWOULDBLOCK on Socket: " << (int)_Socket; return (size_t)dwsend; case WSA_IO_PENDING: throw exception[NetException::Note] << "Socket senddata failed WSA_IO_PENDING on Socket: " << (int)_Socket; return (size_t)dwsend; case WSAENOTCONN: throw exception[NetException::Error] << "Socket senddata failed WSAENOTCONN on Socket: " << (int)_Socket; case WSAECONNRESET: Loading Loading @@ -246,9 +246,9 @@ size_t netplus::tcp::recvData(buffer &data,int flags){ if (rval == SOCKET_ERROR) { switch (WSAGetLastError()) { case WSAEWOULDBLOCK: throw exception[NetException::Note] << "Socket recvData failed WSAWOULDBLOCK on Socket: " << (int)_Socket; return (size_t)dwBytes; case WSA_IO_PENDING: throw exception[NetException::Note] << "Socket recvData failed WSA_IO_PENDING on Socket: " << (int)_Socket; return (size_t)dwBytes; case WSAENOTCONN: throw exception[NetException::Error] << "Socket recvData failed WSAENOTCONN on Socket: " << (int)_Socket; case WSAECONNRESET: Loading
src/windows/udp.cpp +33 −26 Changes for src/windows/udp.cpp: 33 added lines, 26 removed lines. Original line number Diff line number Diff line Loading @@ -189,9 +189,7 @@ void netplus::udp::bind() { } size_t netplus::udp::sendData(buffer &data, int flags) { NetException exception; WSABUF buf; WSABUF buf{ 0 }; if (data.ptr) buf.buf = (char*)data.data.ptr; Loading @@ -200,25 +198,30 @@ size_t netplus::udp::sendData(buffer &data, int flags) { buf.len = static_cast<ULONG>(data.size); DWORD dwBytes = 0; DWORD dwFlags = 0; DWORD dwsend = 0; SOCKET rval = ::WSASend(_Socket, &buf, 1, &dwBytes, flags, &_Overlapped, nullptr); int rval = ::WSASend(_Socket, &buf, 1, &dwsend, flags, &_Overlapped, nullptr); if (rval == SOCKET_ERROR) { int etype = NetException::Error; if (GetLastError() == WSA_IO_PENDING) etype = NetException::Note; NetException exception; exception[etype] << "Socket senddata failed on Socket: " << (int)_Socket << " ErrorMsg: " << GetLastError(); throw exception; if (rval == SOCKET_ERROR) { switch (WSAGetLastError()) { case WSAEWOULDBLOCK: return (size_t)dwsend; case WSA_IO_PENDING: return (size_t)dwsend; case WSAENOTCONN: throw exception[NetException::Error] << "Socket senddata failed WSAENOTCONN on Socket: " << (int)_Socket; case WSAECONNRESET: throw exception[NetException::Error] << "Socket senddata failed WSAECONNRESET on Socket: " << (int)_Socket; default: throw exception[NetException::Error] << "Socket senddata failed some Error on Socket: " << (int)_Socket; } return (size_t)dwBytes; } return (size_t)dwsend; } size_t netplus::udp::recvData(buffer &data, int flags) { NetException exception; if (data.ptr) { Loading @@ -232,20 +235,24 @@ size_t netplus::udp::recvData(buffer &data, int flags) { buf.len = static_cast<ULONG>(data.size); DWORD dwBytes = 0; DWORD dwFlags = 0; int recvsize = ::WSARecv(_Socket, &buf, 1, &dwBytes, (LPDWORD)&flags, &_Overlapped, nullptr); if (recvsize < 0) { int etype = NetException::Error; if (GetLastError() == EAGAIN) etype = NetException::Note; int rval = ::WSARecv(_Socket, &buf, 1, &dwBytes, (LPDWORD)&flags, &_Overlapped, nullptr); exception[etype] << "Socket recvdata failed on Socket: " << (int)_Socket << " ErrorMsg: " << GetLastError(); throw exception; if (rval == SOCKET_ERROR) { switch (WSAGetLastError()) { case WSAEWOULDBLOCK: return (size_t)dwBytes; case WSA_IO_PENDING: return (size_t)dwBytes; case WSAENOTCONN: throw exception[NetException::Error] << "Socket recvData failed WSAENOTCONN on Socket: " << (int)_Socket; case WSAECONNRESET: throw exception[NetException::Error] << "Socket recvData failed WSAECONNRESET on Socket: " << (int)_Socket; default: throw exception[NetException::Error] << "Socket recvData failed some Error on Socket: " << (int)_Socket; } } return (size_t)dwBytes; } void netplus::udp::connect(socket* ssock) { Loading