Loading src/event/epoll.cpp +4 −1 Original line number Diff line number Diff line Loading @@ -103,7 +103,10 @@ namespace netplus { }; ~poll() { delete[] _Events; for (int i = 0; i <_ServerSocket->getMaxconnections(); ++i){ _evtapi->deleteConnetion((netplus::con*)_Events[i].data.ptr); } delete _Events; }; /*basic functions*/ Loading src/posix/tcp.cpp +13 −2 Original line number Diff line number Diff line Loading @@ -123,6 +123,7 @@ netplus::tcp::tcp(const char* addr, int port,int maxconnections,int sockopts) : } netplus::tcp::~tcp(){ if(!_Copy) ::close(_Socket); ::free(_SocketPtr); } Loading @@ -133,16 +134,26 @@ netplus::tcp::tcp() : socket() { ((struct sockaddr*)_SocketPtr)->sa_family=AF_UNSPEC; _Socket=::socket(((struct sockaddr*)_SocketPtr)->sa_family,SOCK_STREAM,0); _Type=sockettype::TCP; _Copy=false; } netplus::tcp::tcp(SOCKET sock) { netplus::tcp::tcp(SOCKET sock) : socket(){ _SocketPtr=::malloc(sizeof(struct sockaddr)); _SocketPtrSize=sizeof(struct sockaddr); ((struct sockaddr*)_SocketPtr)->sa_family=AF_UNSPEC; _Socket=sock; _Type=sockettype::TCP; _Copy=false; } netplus::tcp::tcp(const netplus::tcp& ctcp) : socket (){ _SocketPtr=::malloc(sizeof(ctcp)); _SocketPtrSize=sizeof(ctcp); ((struct sockaddr*)_SocketPtr)->sa_family=((struct sockaddr*)ctcp._SocketPtr)->sa_family; _Socket=ctcp._Socket; _Type=sockettype::TCP; _Copy=true; } void netplus::tcp::listen(){ NetException exception; Loading src/socket.h +2 −1 Original line number Diff line number Diff line Loading @@ -81,7 +81,7 @@ namespace netplus { public: tcp(); tcp(SOCKET socket); tcp(const netplus::tcp& ctcp) = delete; tcp(const netplus::tcp& ctcp); tcp(const char *uxsocket,int maxconnections, int sockopts); tcp(const char *addr,int port,int maxconnections, Loading @@ -108,6 +108,7 @@ namespace netplus { private: int _Maxconnections; std::string _UxPath; bool _Copy; }; class udp : public socket{ Loading src/windows/tcp.cpp +12 −1 Original line number Diff line number Diff line Loading @@ -100,7 +100,7 @@ netplus::tcp::tcp(const char* addr, int port,int maxconnections,int sockopts) : } netplus::tcp::~tcp(){ if(_Socket>=0) if(!_Copy) ::closesocket(_Socket); ::free(_SocketPtr); } Loading @@ -111,6 +111,7 @@ netplus::tcp::tcp() : socket() { ((struct sockaddr*)_SocketPtr)->sa_family=AF_UNSPEC; _Socket=::socket(((struct sockaddr*)_SocketPtr)->sa_family,SOCK_STREAM,0); _Type=sockettype::TCP; _Copy=false; } netplus::tcp::tcp(SOCKET sock) : socket() { Loading @@ -119,6 +120,16 @@ netplus::tcp::tcp(SOCKET sock) : socket() { ((struct addrinfo*)_SocketPtr)->ai_family=AF_UNSPEC; _Socket=sock; _Type=sockettype::TCP; _Copy=false; } netplus::tcp::tcp(const netplus::tcp& ctcp) : socket (){ _SocketPtr=::malloc(sizeof(ctcp)); _SocketPtrSize=sizeof(ctcp); ((struct addrinfo*)_SocketPtr)->ai_family=((struct addrinfo*)ctcp._SocketPtr)->ai_family; _Socket=ctcp._Socket; _Type=sockettype::TCP; _Copy=true; } Loading Loading
src/event/epoll.cpp +4 −1 Original line number Diff line number Diff line Loading @@ -103,7 +103,10 @@ namespace netplus { }; ~poll() { delete[] _Events; for (int i = 0; i <_ServerSocket->getMaxconnections(); ++i){ _evtapi->deleteConnetion((netplus::con*)_Events[i].data.ptr); } delete _Events; }; /*basic functions*/ Loading
src/posix/tcp.cpp +13 −2 Original line number Diff line number Diff line Loading @@ -123,6 +123,7 @@ netplus::tcp::tcp(const char* addr, int port,int maxconnections,int sockopts) : } netplus::tcp::~tcp(){ if(!_Copy) ::close(_Socket); ::free(_SocketPtr); } Loading @@ -133,16 +134,26 @@ netplus::tcp::tcp() : socket() { ((struct sockaddr*)_SocketPtr)->sa_family=AF_UNSPEC; _Socket=::socket(((struct sockaddr*)_SocketPtr)->sa_family,SOCK_STREAM,0); _Type=sockettype::TCP; _Copy=false; } netplus::tcp::tcp(SOCKET sock) { netplus::tcp::tcp(SOCKET sock) : socket(){ _SocketPtr=::malloc(sizeof(struct sockaddr)); _SocketPtrSize=sizeof(struct sockaddr); ((struct sockaddr*)_SocketPtr)->sa_family=AF_UNSPEC; _Socket=sock; _Type=sockettype::TCP; _Copy=false; } netplus::tcp::tcp(const netplus::tcp& ctcp) : socket (){ _SocketPtr=::malloc(sizeof(ctcp)); _SocketPtrSize=sizeof(ctcp); ((struct sockaddr*)_SocketPtr)->sa_family=((struct sockaddr*)ctcp._SocketPtr)->sa_family; _Socket=ctcp._Socket; _Type=sockettype::TCP; _Copy=true; } void netplus::tcp::listen(){ NetException exception; Loading
src/socket.h +2 −1 Original line number Diff line number Diff line Loading @@ -81,7 +81,7 @@ namespace netplus { public: tcp(); tcp(SOCKET socket); tcp(const netplus::tcp& ctcp) = delete; tcp(const netplus::tcp& ctcp); tcp(const char *uxsocket,int maxconnections, int sockopts); tcp(const char *addr,int port,int maxconnections, Loading @@ -108,6 +108,7 @@ namespace netplus { private: int _Maxconnections; std::string _UxPath; bool _Copy; }; class udp : public socket{ Loading
src/windows/tcp.cpp +12 −1 Original line number Diff line number Diff line Loading @@ -100,7 +100,7 @@ netplus::tcp::tcp(const char* addr, int port,int maxconnections,int sockopts) : } netplus::tcp::~tcp(){ if(_Socket>=0) if(!_Copy) ::closesocket(_Socket); ::free(_SocketPtr); } Loading @@ -111,6 +111,7 @@ netplus::tcp::tcp() : socket() { ((struct sockaddr*)_SocketPtr)->sa_family=AF_UNSPEC; _Socket=::socket(((struct sockaddr*)_SocketPtr)->sa_family,SOCK_STREAM,0); _Type=sockettype::TCP; _Copy=false; } netplus::tcp::tcp(SOCKET sock) : socket() { Loading @@ -119,6 +120,16 @@ netplus::tcp::tcp(SOCKET sock) : socket() { ((struct addrinfo*)_SocketPtr)->ai_family=AF_UNSPEC; _Socket=sock; _Type=sockettype::TCP; _Copy=false; } netplus::tcp::tcp(const netplus::tcp& ctcp) : socket (){ _SocketPtr=::malloc(sizeof(ctcp)); _SocketPtrSize=sizeof(ctcp); ((struct addrinfo*)_SocketPtr)->ai_family=((struct addrinfo*)ctcp._SocketPtr)->ai_family; _Socket=ctcp._Socket; _Type=sockettype::TCP; _Copy=true; } Loading