Loading src/event/iocp.cpp +13 −13 Changes for src/event/iocp.cpp: 13 added lines, 13 removed lines. Original line number Diff line number Diff line Loading @@ -196,7 +196,7 @@ namespace netplus { SYSTEM_INFO sysinfo; GetSystemInfo(&sysinfo); threads = 2;// sysinfo.dwNumberOfProcessors; threads = sysinfo.dwNumberOfProcessors; } event::~event() { Loading Loading @@ -247,7 +247,7 @@ namespace netplus { &pOverlapped, WSA_INFINITE); std::lock_guard<std::mutex> lock(EventLock); EventLock.lock(); if (lpContext == 0) { continue; Loading @@ -259,12 +259,17 @@ namespace netplus { eargs->evpoll->RemoveFromClientList(pClientContext); continue; } std::cout.write(pClientContext->CurCon->RecvData.data(), pClientContext->CurCon->RecvData.size())<<std::endl; try { if (!pClientContext->CurCon->SendData.empty()) { try { eargs->event->ResponseEvent(pClientContext->CurCon, tid, args); } catch (NetException& e) { std::cerr << e.what() << std::endl; } dwFlags = 0; ssize = BLOCKSIZE < pClientContext->CurCon->SendData.size() ? BLOCKSIZE : (ULONG)pClientContext->CurCon->SendData.size(); Loading @@ -274,14 +279,8 @@ namespace netplus { pClientContext->CurCon->SendData.resize(ret); try { eargs->event->ResponseEvent(pClientContext->CurCon, tid, args); } catch (NetException& e) { std::cerr << e.what() << std::endl; } } else { WSAResetEvent(pClientContext->CurCon->csock->_Overlapped.hEvent); } else { //Get the data. std::shared_ptr<char[]> buf(new char[BLOCKSIZE], std::default_delete<char[]>()); Loading Loading @@ -319,6 +318,7 @@ namespace netplus { if(e.getErrorType()!=NetException::Note) eargs->evpoll->RemoveFromClientList(pClientContext); } EventLock.unlock(); } // while } }; Loading src/posix/udp.cpp +17 −17 Changes for src/posix/udp.cpp: 17 added lines, 17 removed lines. Original line number Diff line number Diff line Loading @@ -182,29 +182,29 @@ void netplus::udp::bind(){ } size_t netplus::udp::sendData(void* data, unsigned long size,int flags){ WSABUF buf{ 0 }; NetException exception; int rval=::send(_Socket, data, size, flags ); if(rval<0){ int etype=NetException::Error; buf.buf = (char*)data; buf.len = size; if(errno==EAGAIN || errno==EWOULDBLOCK) etype=NetException::Note; DWORD dwFlags = 0; DWORD dwsend = 0; SOCKET rval = ::WSASend(_Socket, &buf, 1, nullptr, flags, &_Overlapped, nullptr); char errstr[512]; strerror_r_netplus(errno,errstr,512); if (rval == SOCKET_ERROR) { DWORD lerror = GetLastError(); exception[etype] << "Socket senddata failed on Socket: " << _Socket << " ErrorMsg: " << errstr; if (lerror == WSA_IO_PENDING) { return (size_t)buf.len; } else { NetException exception; exception[NetException::Error] << "Socket senddata failed on Socket: " << (int)_Socket << " ErrorMsg: " << lerror; throw exception; } return (size_t) rval == 0 ? size : rval; } return (size_t)buf.len; } size_t netplus::udp::recvData(void* data, unsigned long size,int flags){ Loading src/windows/tcp.cpp +11 −12 Changes for src/windows/tcp.cpp: 11 added lines, 12 removed lines. Original line number Diff line number Diff line Loading @@ -191,30 +191,29 @@ void netplus::tcp::bind(){ size_t netplus::tcp::sendData(void* data, unsigned long size,int flags){ NetException exception; WSABUF buf{0}; buf.buf = (char*)data; buf.len = size; DWORD dwFlags = 0; SOCKET rval=::WSASend(_Socket,&buf,1,nullptr,flags,&_Overlapped,nullptr); DWORD dwsend = 0; SOCKET rval=::WSASend(_Socket,&buf,1,&dwsend,flags,&_Overlapped,nullptr); if(rval == SOCKET_ERROR){ DWORD lerror=GetLastError(); int etype = NetException::Error; if (lerror == WSA_IO_PENDING) { etype = NetException::Note; } exception[etype] << "Socket senddata failed on Socket: " << (int) _Socket return (size_t)dwsend; } else { NetException exception; exception[NetException::Error] << "Socket senddata failed on Socket: " << (int)_Socket << " ErrorMsg: " << lerror; throw exception; } return (size_t) rval; } return (size_t)dwsend; } size_t netplus::tcp::recvData(void* data, unsigned long size,int flags){ Loading @@ -238,11 +237,11 @@ size_t netplus::tcp::recvData(void* data, unsigned long size,int flags){ << " ErrorMsg: " << lerror; throw exception; } else { return buf.len; return dwBytes; } } return (size_t) buf.len; return (size_t)dwBytes; } void netplus::tcp::connect(socket *ssock){ Loading Loading
src/event/iocp.cpp +13 −13 Changes for src/event/iocp.cpp: 13 added lines, 13 removed lines. Original line number Diff line number Diff line Loading @@ -196,7 +196,7 @@ namespace netplus { SYSTEM_INFO sysinfo; GetSystemInfo(&sysinfo); threads = 2;// sysinfo.dwNumberOfProcessors; threads = sysinfo.dwNumberOfProcessors; } event::~event() { Loading Loading @@ -247,7 +247,7 @@ namespace netplus { &pOverlapped, WSA_INFINITE); std::lock_guard<std::mutex> lock(EventLock); EventLock.lock(); if (lpContext == 0) { continue; Loading @@ -259,12 +259,17 @@ namespace netplus { eargs->evpoll->RemoveFromClientList(pClientContext); continue; } std::cout.write(pClientContext->CurCon->RecvData.data(), pClientContext->CurCon->RecvData.size())<<std::endl; try { if (!pClientContext->CurCon->SendData.empty()) { try { eargs->event->ResponseEvent(pClientContext->CurCon, tid, args); } catch (NetException& e) { std::cerr << e.what() << std::endl; } dwFlags = 0; ssize = BLOCKSIZE < pClientContext->CurCon->SendData.size() ? BLOCKSIZE : (ULONG)pClientContext->CurCon->SendData.size(); Loading @@ -274,14 +279,8 @@ namespace netplus { pClientContext->CurCon->SendData.resize(ret); try { eargs->event->ResponseEvent(pClientContext->CurCon, tid, args); } catch (NetException& e) { std::cerr << e.what() << std::endl; } } else { WSAResetEvent(pClientContext->CurCon->csock->_Overlapped.hEvent); } else { //Get the data. std::shared_ptr<char[]> buf(new char[BLOCKSIZE], std::default_delete<char[]>()); Loading Loading @@ -319,6 +318,7 @@ namespace netplus { if(e.getErrorType()!=NetException::Note) eargs->evpoll->RemoveFromClientList(pClientContext); } EventLock.unlock(); } // while } }; Loading
src/posix/udp.cpp +17 −17 Changes for src/posix/udp.cpp: 17 added lines, 17 removed lines. Original line number Diff line number Diff line Loading @@ -182,29 +182,29 @@ void netplus::udp::bind(){ } size_t netplus::udp::sendData(void* data, unsigned long size,int flags){ WSABUF buf{ 0 }; NetException exception; int rval=::send(_Socket, data, size, flags ); if(rval<0){ int etype=NetException::Error; buf.buf = (char*)data; buf.len = size; if(errno==EAGAIN || errno==EWOULDBLOCK) etype=NetException::Note; DWORD dwFlags = 0; DWORD dwsend = 0; SOCKET rval = ::WSASend(_Socket, &buf, 1, nullptr, flags, &_Overlapped, nullptr); char errstr[512]; strerror_r_netplus(errno,errstr,512); if (rval == SOCKET_ERROR) { DWORD lerror = GetLastError(); exception[etype] << "Socket senddata failed on Socket: " << _Socket << " ErrorMsg: " << errstr; if (lerror == WSA_IO_PENDING) { return (size_t)buf.len; } else { NetException exception; exception[NetException::Error] << "Socket senddata failed on Socket: " << (int)_Socket << " ErrorMsg: " << lerror; throw exception; } return (size_t) rval == 0 ? size : rval; } return (size_t)buf.len; } size_t netplus::udp::recvData(void* data, unsigned long size,int flags){ Loading
src/windows/tcp.cpp +11 −12 Changes for src/windows/tcp.cpp: 11 added lines, 12 removed lines. Original line number Diff line number Diff line Loading @@ -191,30 +191,29 @@ void netplus::tcp::bind(){ size_t netplus::tcp::sendData(void* data, unsigned long size,int flags){ NetException exception; WSABUF buf{0}; buf.buf = (char*)data; buf.len = size; DWORD dwFlags = 0; SOCKET rval=::WSASend(_Socket,&buf,1,nullptr,flags,&_Overlapped,nullptr); DWORD dwsend = 0; SOCKET rval=::WSASend(_Socket,&buf,1,&dwsend,flags,&_Overlapped,nullptr); if(rval == SOCKET_ERROR){ DWORD lerror=GetLastError(); int etype = NetException::Error; if (lerror == WSA_IO_PENDING) { etype = NetException::Note; } exception[etype] << "Socket senddata failed on Socket: " << (int) _Socket return (size_t)dwsend; } else { NetException exception; exception[NetException::Error] << "Socket senddata failed on Socket: " << (int)_Socket << " ErrorMsg: " << lerror; throw exception; } return (size_t) rval; } return (size_t)dwsend; } size_t netplus::tcp::recvData(void* data, unsigned long size,int flags){ Loading @@ -238,11 +237,11 @@ size_t netplus::tcp::recvData(void* data, unsigned long size,int flags){ << " ErrorMsg: " << lerror; throw exception; } else { return buf.len; return dwBytes; } } return (size_t) buf.len; return (size_t)dwBytes; } void netplus::tcp::connect(socket *ssock){ Loading