Loading src/connection.h +1 −1 Changes for src/connection.h: 1 added line, 1 removed line. Original line number Diff line number Diff line Loading @@ -150,7 +150,7 @@ namespace netplus { virtual ~con(); /*clientsocket*/ std::shared_ptr<socket> csock; std::unique_ptr<socket> csock; /*event stauts*/ int state; Loading src/event/epoll.cpp +26 −13 Changes for src/event/epoll.cpp: 26 added lines, 13 removed lines. Original line number Diff line number Diff line Loading @@ -57,6 +57,19 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define BLOCKSIZE 16384 namespace netplus { bool RUNNING=true; void signalHandler(int signum) { switch(signum){ case SIGINT: RUNNING=false; break; default: break; } } class pollapi { public: pollapi(eventapi *evcon,int timeout) : evconnection(evcon){ Loading Loading @@ -86,13 +99,14 @@ namespace netplus { class poll : public pollapi{ public: poll(socket *serversocket,eventapi *evcon,int pollfd,int timeout) : pollapi(evcon,timeout), _ServerSocket (serversocket){ pollapi(evcon,timeout), _pollFD(pollfd), _Events(new struct epoll_event[serversocket->getMaxconnections()]), _ServerSocket (serversocket), _Timeout(timeout) { NetException exception; _Timeout=timeout; _pollFD=pollfd; _Events = std::shared_ptr<struct epoll_event[]>(new struct epoll_event[_ServerSocket->getMaxconnections()]); int maxcon=_ServerSocket->getMaxconnections(); for (int i = 0; i <maxcon; ++i){ _Events[i].events=-1; Loading @@ -102,9 +116,6 @@ namespace netplus { }; ~poll() { for (int i = 0; i <_ServerSocket->getMaxconnections(); ++i){ delete static_cast<con*>(_Events[i].data.ptr); } }; /*basic functions*/ Loading Loading @@ -162,11 +173,11 @@ namespace netplus { evconnection->CreateConnection(ccon); if(_ServerSocket->_Type==sockettype::TCP){ ccon->csock=std::make_shared<tcp>(-1); ccon->csock=std::make_unique<tcp>(-1); }else if(_ServerSocket->_Type==sockettype::UDP){ ccon->csock=std::make_shared<udp>(-1); ccon->csock=std::make_unique<udp>(-1); }else if(_ServerSocket->_Type==sockettype::SSL){ // clt->connection->csock=std::make_shared<ssl>( -1); // clt->connection->csock=std::make_unique<ssl>( -1); } _ServerSocket->accept(ccon->csock); Loading Loading @@ -281,7 +292,6 @@ namespace netplus { evconnection->DisconnectEvent(*ccon,tid,args); delete ccon; _Events[pos].data.ptr=nullptr; } }catch(NetException &e){ throw e; Loading Loading @@ -327,7 +337,8 @@ namespace netplus { poll pollptr(eargs->ssocket,eargs->event,eargs->pollfd, eargs->timeout); int wait=0; for(;;){ while(RUNNING){ try { wait=pollptr.waitEventHandler(eargs->timeout); for(int i =0; i<wait; ++i){ Loading Loading @@ -409,6 +420,8 @@ namespace netplus { void event::runEventloop(ULONG_PTR args) { NetException exception; signal(SIGINT, signalHandler); signal(SIGPIPE, SIG_IGN); MAINWORKERLOOP: Loading src/eventapi.h +1 −1 Changes for src/eventapi.h: 1 added line, 1 removed line. Original line number Diff line number Diff line Loading @@ -53,7 +53,7 @@ namespace netplus { class event :public eventapi { public: event(socket *serversocket, int timeout=-1); event(socket *serversocket, int timeout=1000); void runEventloop(ULONG_PTR args=0); Loading src/posix/tcp.cpp +2 −2 Changes for src/posix/tcp.cpp: 2 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -153,7 +153,7 @@ int netplus::tcp::getMaxconnections(){ return _Maxconnections; } void netplus::tcp::accept(std::shared_ptr<socket> &csock){ void netplus::tcp::accept(std::unique_ptr<socket> &csock){ NetException exception; copyAddrInfo(&csock->_SocketInfo,_SocketInfo,_SocketInfoLen); Loading Loading @@ -241,7 +241,7 @@ size_t netplus::tcp::recvData(buffer &data,int flags){ return (size_t)recvsize != 0 ? recvsize : data.size; } void netplus::tcp::connect(std::shared_ptr<socket> &csock){ void netplus::tcp::connect(std::unique_ptr<socket> &csock){ NetException exception; copyAddrInfo(&_SocketInfo,csock->_SocketInfo, csock->_SocketInfoLen); Loading src/posix/udp.cpp +3 −2 Changes for src/posix/udp.cpp: 3 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include <chrono> #include <thread> #include <cstring> #include <memory> #include <vector> #include <cstdio> Loading Loading @@ -153,7 +154,7 @@ int netplus::udp::getMaxconnections(){ return _Maxconnections; } void netplus::udp::accept(std::shared_ptr<socket> &csock){ void netplus::udp::accept(std::unique_ptr<socket> &csock){ NetException exception; ((struct addrinfo *)(csock->_SocketInfo))->ai_addr=(struct sockaddr*) malloc(((struct addrinfo *)(_SocketInfo))->ai_addrlen); Loading Loading @@ -241,7 +242,7 @@ size_t netplus::udp::recvData(buffer &data,int flags){ return (size_t)recvsize != 0 ? recvsize : data.size; } void netplus::udp::connect(std::shared_ptr<socket> &csock){ void netplus::udp::connect(std::unique_ptr<socket> &csock){ NetException exception; copyAddrInfo(&_SocketInfo,csock->_SocketInfo,csock->_SocketInfoLen); Loading Loading
src/connection.h +1 −1 Changes for src/connection.h: 1 added line, 1 removed line. Original line number Diff line number Diff line Loading @@ -150,7 +150,7 @@ namespace netplus { virtual ~con(); /*clientsocket*/ std::shared_ptr<socket> csock; std::unique_ptr<socket> csock; /*event stauts*/ int state; Loading
src/event/epoll.cpp +26 −13 Changes for src/event/epoll.cpp: 26 added lines, 13 removed lines. Original line number Diff line number Diff line Loading @@ -57,6 +57,19 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define BLOCKSIZE 16384 namespace netplus { bool RUNNING=true; void signalHandler(int signum) { switch(signum){ case SIGINT: RUNNING=false; break; default: break; } } class pollapi { public: pollapi(eventapi *evcon,int timeout) : evconnection(evcon){ Loading Loading @@ -86,13 +99,14 @@ namespace netplus { class poll : public pollapi{ public: poll(socket *serversocket,eventapi *evcon,int pollfd,int timeout) : pollapi(evcon,timeout), _ServerSocket (serversocket){ pollapi(evcon,timeout), _pollFD(pollfd), _Events(new struct epoll_event[serversocket->getMaxconnections()]), _ServerSocket (serversocket), _Timeout(timeout) { NetException exception; _Timeout=timeout; _pollFD=pollfd; _Events = std::shared_ptr<struct epoll_event[]>(new struct epoll_event[_ServerSocket->getMaxconnections()]); int maxcon=_ServerSocket->getMaxconnections(); for (int i = 0; i <maxcon; ++i){ _Events[i].events=-1; Loading @@ -102,9 +116,6 @@ namespace netplus { }; ~poll() { for (int i = 0; i <_ServerSocket->getMaxconnections(); ++i){ delete static_cast<con*>(_Events[i].data.ptr); } }; /*basic functions*/ Loading Loading @@ -162,11 +173,11 @@ namespace netplus { evconnection->CreateConnection(ccon); if(_ServerSocket->_Type==sockettype::TCP){ ccon->csock=std::make_shared<tcp>(-1); ccon->csock=std::make_unique<tcp>(-1); }else if(_ServerSocket->_Type==sockettype::UDP){ ccon->csock=std::make_shared<udp>(-1); ccon->csock=std::make_unique<udp>(-1); }else if(_ServerSocket->_Type==sockettype::SSL){ // clt->connection->csock=std::make_shared<ssl>( -1); // clt->connection->csock=std::make_unique<ssl>( -1); } _ServerSocket->accept(ccon->csock); Loading Loading @@ -281,7 +292,6 @@ namespace netplus { evconnection->DisconnectEvent(*ccon,tid,args); delete ccon; _Events[pos].data.ptr=nullptr; } }catch(NetException &e){ throw e; Loading Loading @@ -327,7 +337,8 @@ namespace netplus { poll pollptr(eargs->ssocket,eargs->event,eargs->pollfd, eargs->timeout); int wait=0; for(;;){ while(RUNNING){ try { wait=pollptr.waitEventHandler(eargs->timeout); for(int i =0; i<wait; ++i){ Loading Loading @@ -409,6 +420,8 @@ namespace netplus { void event::runEventloop(ULONG_PTR args) { NetException exception; signal(SIGINT, signalHandler); signal(SIGPIPE, SIG_IGN); MAINWORKERLOOP: Loading
src/eventapi.h +1 −1 Changes for src/eventapi.h: 1 added line, 1 removed line. Original line number Diff line number Diff line Loading @@ -53,7 +53,7 @@ namespace netplus { class event :public eventapi { public: event(socket *serversocket, int timeout=-1); event(socket *serversocket, int timeout=1000); void runEventloop(ULONG_PTR args=0); Loading
src/posix/tcp.cpp +2 −2 Changes for src/posix/tcp.cpp: 2 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -153,7 +153,7 @@ int netplus::tcp::getMaxconnections(){ return _Maxconnections; } void netplus::tcp::accept(std::shared_ptr<socket> &csock){ void netplus::tcp::accept(std::unique_ptr<socket> &csock){ NetException exception; copyAddrInfo(&csock->_SocketInfo,_SocketInfo,_SocketInfoLen); Loading Loading @@ -241,7 +241,7 @@ size_t netplus::tcp::recvData(buffer &data,int flags){ return (size_t)recvsize != 0 ? recvsize : data.size; } void netplus::tcp::connect(std::shared_ptr<socket> &csock){ void netplus::tcp::connect(std::unique_ptr<socket> &csock){ NetException exception; copyAddrInfo(&_SocketInfo,csock->_SocketInfo, csock->_SocketInfoLen); Loading
src/posix/udp.cpp +3 −2 Changes for src/posix/udp.cpp: 3 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include <chrono> #include <thread> #include <cstring> #include <memory> #include <vector> #include <cstdio> Loading Loading @@ -153,7 +154,7 @@ int netplus::udp::getMaxconnections(){ return _Maxconnections; } void netplus::udp::accept(std::shared_ptr<socket> &csock){ void netplus::udp::accept(std::unique_ptr<socket> &csock){ NetException exception; ((struct addrinfo *)(csock->_SocketInfo))->ai_addr=(struct sockaddr*) malloc(((struct addrinfo *)(_SocketInfo))->ai_addrlen); Loading Loading @@ -241,7 +242,7 @@ size_t netplus::udp::recvData(buffer &data,int flags){ return (size_t)recvsize != 0 ? recvsize : data.size; } void netplus::udp::connect(std::shared_ptr<socket> &csock){ void netplus::udp::connect(std::unique_ptr<socket> &csock){ NetException exception; copyAddrInfo(&_SocketInfo,csock->_SocketInfo,csock->_SocketInfoLen); Loading