Commit a66ac552 authored by jan.koester's avatar jan.koester
Browse files

copy cons added

parent 8dcc6f77
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -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*/
+13 −2
Original line number Diff line number Diff line
@@ -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);
}
@@ -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;
+2 −1
Original line number Diff line number Diff line
@@ -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,
@@ -108,6 +108,7 @@ namespace netplus {
        private:
            int             _Maxconnections;
            std::string     _UxPath;
            bool            _Copy;
        };
        
        class udp : public socket{
+12 −1
Original line number Diff line number Diff line
@@ -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);
}
@@ -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() {
@@ -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;
}