Loading src/event/epoll.cpp +10 −4 Changes for src/event/epoll.cpp: 10 added lines, 4 removed lines. Original line number Diff line number Diff line Loading @@ -101,13 +101,18 @@ namespace netplus { poll(socket *serversocket,eventapi *evcon,int pollfd,int timeout) : pollapi(evcon,timeout), _pollFD(pollfd), _Events(new struct epoll_event[serversocket->getMaxconnections()]), _Events( new epoll_event[serversocket->getMaxconnections()] ), _ServerSocket (serversocket), _Timeout(timeout) { NetException exception; int maxcon=_ServerSocket->getMaxconnections(); NetException exception; for (int i = 0; i <maxcon; ++i){ _Events[i].events=-1; _Events[i].data.fd=-1; Loading Loading @@ -300,9 +305,10 @@ namespace netplus { }; private: int _pollFD; std::shared_ptr<struct epoll_event[]> _Events; std::shared_ptr<socket> _ServerSocket; std::unique_ptr<struct epoll_event[]> _Events; std::unique_ptr<socket> _ServerSocket; int _Timeout; }; Loading src/posix/socket.cpp +4 −2 Changes for src/posix/socket.cpp: 4 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -57,14 +57,16 @@ netplus::socket::socket(){ _SocketInfoLen=sizeof(struct addrinfo); memset((void*)_SocketInfo,0,sizeof(struct addrinfo)); _Type=-1; ++_InitCount; } netplus::socket::~socket(){ --_InitCount; if(_InitCount==0){ if(_SocketInfo){ free(((struct addrinfo*)_SocketInfo)->ai_addr); free((void*)_SocketInfo); } } } void netplus::socket::setFlag(int flag,int value){ int sockopts=fcntl(_Socket, F_GETFL, 0); Loading src/posix/tcp.cpp +3 −1 Changes for src/posix/tcp.cpp: 3 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -116,7 +116,8 @@ netplus::tcp::tcp(const std::string &addr, int port,int maxconnections,int socko } netplus::tcp::~tcp(){ if(_Socket!=-1) --_InitCount; if(_Socket!=-1 && _InitCount <=0) ::close(_Socket); } Loading @@ -129,6 +130,7 @@ netplus::tcp::tcp(SOCKET sock) :socket(){ ((struct addrinfo*)_SocketInfo)->ai_family=AF_UNSPEC; _Socket=sock; _Type=sockettype::TCP; ++_InitCount; } void netplus::tcp::listen(){ Loading src/posix/udp.cpp +4 −1 Changes for src/posix/udp.cpp: 4 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -117,19 +117,22 @@ netplus::udp::udp(const std::string &addr, int port,int maxconnections,int socko } netplus::udp::~udp(){ if(_Socket!=-1) --_InitCount; if(_Socket!=-1 && _InitCount <=0) ::close(_Socket); } netplus::udp::udp() : socket() { _Socket=-1; _Type=sockettype::UDP; ++_InitCount; } netplus::udp::udp(SOCKET sock) : socket(){ ((struct addrinfo*)_SocketInfo)->ai_family=AF_UNSPEC; _Socket=sock; _Type=sockettype::UDP; ++_InitCount; } void netplus::udp::listen(){ Loading src/socket.h +1 −1 Changes for src/socket.h: 1 added line, 1 removed line. Original line number Diff line number Diff line Loading @@ -126,7 +126,7 @@ namespace netplus { class tcp : public socket{ public: tcp(); tcp(SOCKET socket); tcp(SOCKET sock); tcp(const netplus::tcp& ctcp) = delete; tcp(const std::string &uxsocket,int maxconnections, int sockopts); Loading Loading
src/event/epoll.cpp +10 −4 Changes for src/event/epoll.cpp: 10 added lines, 4 removed lines. Original line number Diff line number Diff line Loading @@ -101,13 +101,18 @@ namespace netplus { poll(socket *serversocket,eventapi *evcon,int pollfd,int timeout) : pollapi(evcon,timeout), _pollFD(pollfd), _Events(new struct epoll_event[serversocket->getMaxconnections()]), _Events( new epoll_event[serversocket->getMaxconnections()] ), _ServerSocket (serversocket), _Timeout(timeout) { NetException exception; int maxcon=_ServerSocket->getMaxconnections(); NetException exception; for (int i = 0; i <maxcon; ++i){ _Events[i].events=-1; _Events[i].data.fd=-1; Loading Loading @@ -300,9 +305,10 @@ namespace netplus { }; private: int _pollFD; std::shared_ptr<struct epoll_event[]> _Events; std::shared_ptr<socket> _ServerSocket; std::unique_ptr<struct epoll_event[]> _Events; std::unique_ptr<socket> _ServerSocket; int _Timeout; }; Loading
src/posix/socket.cpp +4 −2 Changes for src/posix/socket.cpp: 4 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -57,14 +57,16 @@ netplus::socket::socket(){ _SocketInfoLen=sizeof(struct addrinfo); memset((void*)_SocketInfo,0,sizeof(struct addrinfo)); _Type=-1; ++_InitCount; } netplus::socket::~socket(){ --_InitCount; if(_InitCount==0){ if(_SocketInfo){ free(((struct addrinfo*)_SocketInfo)->ai_addr); free((void*)_SocketInfo); } } } void netplus::socket::setFlag(int flag,int value){ int sockopts=fcntl(_Socket, F_GETFL, 0); Loading
src/posix/tcp.cpp +3 −1 Changes for src/posix/tcp.cpp: 3 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -116,7 +116,8 @@ netplus::tcp::tcp(const std::string &addr, int port,int maxconnections,int socko } netplus::tcp::~tcp(){ if(_Socket!=-1) --_InitCount; if(_Socket!=-1 && _InitCount <=0) ::close(_Socket); } Loading @@ -129,6 +130,7 @@ netplus::tcp::tcp(SOCKET sock) :socket(){ ((struct addrinfo*)_SocketInfo)->ai_family=AF_UNSPEC; _Socket=sock; _Type=sockettype::TCP; ++_InitCount; } void netplus::tcp::listen(){ Loading
src/posix/udp.cpp +4 −1 Changes for src/posix/udp.cpp: 4 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -117,19 +117,22 @@ netplus::udp::udp(const std::string &addr, int port,int maxconnections,int socko } netplus::udp::~udp(){ if(_Socket!=-1) --_InitCount; if(_Socket!=-1 && _InitCount <=0) ::close(_Socket); } netplus::udp::udp() : socket() { _Socket=-1; _Type=sockettype::UDP; ++_InitCount; } netplus::udp::udp(SOCKET sock) : socket(){ ((struct addrinfo*)_SocketInfo)->ai_family=AF_UNSPEC; _Socket=sock; _Type=sockettype::UDP; ++_InitCount; } void netplus::udp::listen(){ Loading
src/socket.h +1 −1 Changes for src/socket.h: 1 added line, 1 removed line. Original line number Diff line number Diff line Loading @@ -126,7 +126,7 @@ namespace netplus { class tcp : public socket{ public: tcp(); tcp(SOCKET socket); tcp(SOCKET sock); tcp(const netplus::tcp& ctcp) = delete; tcp(const std::string &uxsocket,int maxconnections, int sockopts); Loading