Loading CMakeLists.txt +1 −1 Changes for CMakeLists.txt: 1 added line, 1 removed line. Original line number Diff line number Diff line Loading @@ -15,7 +15,7 @@ if(${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Linux") "${CMAKE_CXX_FLAGS} \ -fPIC \ -Wall \ -Woverloaded-virtual " " ) set(CMAKE_C_FLAGS Loading src/connection.cpp +7 −15 Changes for src/connection.cpp: 7 added lines, 15 removed lines. Original line number Diff line number Diff line Loading @@ -62,21 +62,17 @@ netplus::condata<char>::condata(const std::vector<char> &src){ } void netplus::condata<char>::resize(size_t size_c){ size_t rs = std::vector<char,condataAlloc<char>>::size(); size_t rs = size(); std::move( std::vector<char,condataAlloc<char>>::begin()+size_c, std::vector<char,condataAlloc<char>>::end(), std::vector<char,condataAlloc<char>>::begin() begin()+size_c, end(), begin() ); std::vector<char,condataAlloc<char>>::resize(rs-size_c); } bool netplus::condata<char>::empty(){ return std::vector<char, condataAlloc<char>>::empty(); } void netplus::condata<char>::append(const char* data, size_t datalen){ if (data == data + datalen) return; Loading @@ -85,14 +81,14 @@ void netplus::condata<char>::append(const char* data, size_t datalen){ size_t netplus::condata<char>::search(const char* word,size_t pos){ size_t wsize=strlen(word); for(size_t i=pos; i<std::vector<char,condataAlloc<char>>::size(); ++i){ for(size_t i=pos; i<size(); ++i){ for(size_t ii=0; ii<=wsize; ++ii){ if(ii==wsize){ return i-wsize; } if(i>=std::vector<char,condataAlloc<char>>::size() || ii>=wsize) if(i>=size() || ii>=wsize) break; if(std::vector<char,condataAlloc<char>>::at(i)==word[ii]){ if(at(i)==word[ii]){ ++i; continue; } Loading @@ -107,10 +103,6 @@ size_t netplus::condata<char>::search(const char* word){ return search(word,0); } void netplus::condata<char>::push_back(char a){ std::vector<char, netplus::condataAlloc<char> >::push_back(a); } netplus::con::con() : csock(nullptr){ state=0; lasteventime = time(nullptr); Loading src/connection.h −2 Changes for src/connection.h: 0 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -139,9 +139,7 @@ namespace netplus { void append(const char *data,size_t datalen); size_t search(const char *word); size_t search(const char *word,size_t pos); void push_back(char a); size_t pos; bool empty(); }; class con { Loading src/event/epoll.cpp +5 −8 Changes for src/event/epoll.cpp: 5 added lines, 8 removed lines. Original line number Diff line number Diff line Loading @@ -199,18 +199,16 @@ namespace netplus { void ReadEventHandler(int pos,const int tid,ULONG_PTR args) { con *rcon = reinterpret_cast<con*>(_Events[pos].data.ptr); char *buf=new char[BLOCKSIZE]; buffer buf(BLOCKSIZE); try{ size_t rcvsize = rcon->csock->recvData(&buf, BLOCKSIZE); std::cerr.write(buf,rcvsize)<<std::endl; size_t rcvsize = rcon->csock->recvData(buf, BLOCKSIZE); rcon->lasteventime = time(nullptr); if(rcvsize!=0){ rcon->RecvData.append(buf,rcvsize); rcon->RecvData.append(buf.data.buf,rcvsize); rcon->state=EVIN; } Loading @@ -225,7 +223,6 @@ namespace netplus { setpollEvents(pos,EPOLLIN | EPOLLONESHOT); }catch(NetException &e){ delete[] buf; if(e.getErrorType()== NetException::Note){ rcon->state=EVIN; setpollEvents(pos,EPOLLIN | EPOLLONESHOT); Loading @@ -233,7 +230,6 @@ namespace netplus { } throw e; } delete[] buf; }; void WriteEventHandler(int pos,const int tid,ULONG_PTR args) { Loading @@ -251,7 +247,8 @@ namespace netplus { size_t ssize = BLOCKSIZE < wcon->SendData.size() ? BLOCKSIZE : wcon->SendData.size(); wcon->state=EVOUT; size_t sended = wcon->csock->sendData(wcon->SendData.data(),ssize); buffer buf(wcon->SendData.data(),ssize); size_t sended = wcon->csock->sendData(buf); wcon->SendData.resize(sended); wcon->lasteventime = time(nullptr); Loading src/posix/tcp.cpp +17 −7 Changes for src/posix/tcp.cpp: 17 added lines, 7 removed lines. Original line number Diff line number Diff line Loading @@ -180,11 +180,16 @@ void netplus::tcp::bind(){ } } size_t netplus::tcp::sendData(const char *data,size_t size,int flags){ size_t netplus::tcp::sendData(buffer &data,int flags){ NetException exception; int rval=::send(_Socket,data,size,flags); int rval=0; if(data.ptr) rval=::send(_Socket,data.data.ptr,data.size,flags); else rval=::send(_Socket,data.data.buf,data.size,flags); if(rval<0){ int etype=NetException::Error; Loading @@ -200,17 +205,22 @@ size_t netplus::tcp::sendData(const char *data,size_t size,int flags){ throw exception; } return (size_t) rval != 0 ? rval : size; return (size_t) rval != 0 ? rval : data.size; } size_t netplus::tcp::recvData(char **data,size_t size,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; } int recvsize=::recv(_Socket, *data, size, data.data.buf, data.size, flags ); Loading @@ -228,7 +238,7 @@ size_t netplus::tcp::recvData(char **data,size_t size,int flags){ << " ErrorMsg: " << errstr; throw exception; } return (size_t)recvsize != 0 ? recvsize : size; return (size_t)recvsize != 0 ? recvsize : data.size; } void netplus::tcp::connect(socket *ssock){ Loading Loading
CMakeLists.txt +1 −1 Changes for CMakeLists.txt: 1 added line, 1 removed line. Original line number Diff line number Diff line Loading @@ -15,7 +15,7 @@ if(${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Linux") "${CMAKE_CXX_FLAGS} \ -fPIC \ -Wall \ -Woverloaded-virtual " " ) set(CMAKE_C_FLAGS Loading
src/connection.cpp +7 −15 Changes for src/connection.cpp: 7 added lines, 15 removed lines. Original line number Diff line number Diff line Loading @@ -62,21 +62,17 @@ netplus::condata<char>::condata(const std::vector<char> &src){ } void netplus::condata<char>::resize(size_t size_c){ size_t rs = std::vector<char,condataAlloc<char>>::size(); size_t rs = size(); std::move( std::vector<char,condataAlloc<char>>::begin()+size_c, std::vector<char,condataAlloc<char>>::end(), std::vector<char,condataAlloc<char>>::begin() begin()+size_c, end(), begin() ); std::vector<char,condataAlloc<char>>::resize(rs-size_c); } bool netplus::condata<char>::empty(){ return std::vector<char, condataAlloc<char>>::empty(); } void netplus::condata<char>::append(const char* data, size_t datalen){ if (data == data + datalen) return; Loading @@ -85,14 +81,14 @@ void netplus::condata<char>::append(const char* data, size_t datalen){ size_t netplus::condata<char>::search(const char* word,size_t pos){ size_t wsize=strlen(word); for(size_t i=pos; i<std::vector<char,condataAlloc<char>>::size(); ++i){ for(size_t i=pos; i<size(); ++i){ for(size_t ii=0; ii<=wsize; ++ii){ if(ii==wsize){ return i-wsize; } if(i>=std::vector<char,condataAlloc<char>>::size() || ii>=wsize) if(i>=size() || ii>=wsize) break; if(std::vector<char,condataAlloc<char>>::at(i)==word[ii]){ if(at(i)==word[ii]){ ++i; continue; } Loading @@ -107,10 +103,6 @@ size_t netplus::condata<char>::search(const char* word){ return search(word,0); } void netplus::condata<char>::push_back(char a){ std::vector<char, netplus::condataAlloc<char> >::push_back(a); } netplus::con::con() : csock(nullptr){ state=0; lasteventime = time(nullptr); Loading
src/connection.h −2 Changes for src/connection.h: 0 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -139,9 +139,7 @@ namespace netplus { void append(const char *data,size_t datalen); size_t search(const char *word); size_t search(const char *word,size_t pos); void push_back(char a); size_t pos; bool empty(); }; class con { Loading
src/event/epoll.cpp +5 −8 Changes for src/event/epoll.cpp: 5 added lines, 8 removed lines. Original line number Diff line number Diff line Loading @@ -199,18 +199,16 @@ namespace netplus { void ReadEventHandler(int pos,const int tid,ULONG_PTR args) { con *rcon = reinterpret_cast<con*>(_Events[pos].data.ptr); char *buf=new char[BLOCKSIZE]; buffer buf(BLOCKSIZE); try{ size_t rcvsize = rcon->csock->recvData(&buf, BLOCKSIZE); std::cerr.write(buf,rcvsize)<<std::endl; size_t rcvsize = rcon->csock->recvData(buf, BLOCKSIZE); rcon->lasteventime = time(nullptr); if(rcvsize!=0){ rcon->RecvData.append(buf,rcvsize); rcon->RecvData.append(buf.data.buf,rcvsize); rcon->state=EVIN; } Loading @@ -225,7 +223,6 @@ namespace netplus { setpollEvents(pos,EPOLLIN | EPOLLONESHOT); }catch(NetException &e){ delete[] buf; if(e.getErrorType()== NetException::Note){ rcon->state=EVIN; setpollEvents(pos,EPOLLIN | EPOLLONESHOT); Loading @@ -233,7 +230,6 @@ namespace netplus { } throw e; } delete[] buf; }; void WriteEventHandler(int pos,const int tid,ULONG_PTR args) { Loading @@ -251,7 +247,8 @@ namespace netplus { size_t ssize = BLOCKSIZE < wcon->SendData.size() ? BLOCKSIZE : wcon->SendData.size(); wcon->state=EVOUT; size_t sended = wcon->csock->sendData(wcon->SendData.data(),ssize); buffer buf(wcon->SendData.data(),ssize); size_t sended = wcon->csock->sendData(buf); wcon->SendData.resize(sended); wcon->lasteventime = time(nullptr); Loading
src/posix/tcp.cpp +17 −7 Changes for src/posix/tcp.cpp: 17 added lines, 7 removed lines. Original line number Diff line number Diff line Loading @@ -180,11 +180,16 @@ void netplus::tcp::bind(){ } } size_t netplus::tcp::sendData(const char *data,size_t size,int flags){ size_t netplus::tcp::sendData(buffer &data,int flags){ NetException exception; int rval=::send(_Socket,data,size,flags); int rval=0; if(data.ptr) rval=::send(_Socket,data.data.ptr,data.size,flags); else rval=::send(_Socket,data.data.buf,data.size,flags); if(rval<0){ int etype=NetException::Error; Loading @@ -200,17 +205,22 @@ size_t netplus::tcp::sendData(const char *data,size_t size,int flags){ throw exception; } return (size_t) rval != 0 ? rval : size; return (size_t) rval != 0 ? rval : data.size; } size_t netplus::tcp::recvData(char **data,size_t size,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; } int recvsize=::recv(_Socket, *data, size, data.data.buf, data.size, flags ); Loading @@ -228,7 +238,7 @@ size_t netplus::tcp::recvData(char **data,size_t size,int flags){ << " ErrorMsg: " << errstr; throw exception; } return (size_t)recvsize != 0 ? recvsize : size; return (size_t)recvsize != 0 ? recvsize : data.size; } void netplus::tcp::connect(socket *ssock){ Loading