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

copy constructor for udp and tcp

parent 2230f6c7
Loading
Loading
Loading
Loading
+24 −0
Original line number Diff line number Diff line
@@ -61,6 +61,17 @@ int netplus::socket::getSocket(){
    return _Socket;
}

netplus::tcp::tcp(netplus::tcp& ctcp){
    _Socket=ctcp._Socket;
    if(_UxPath.empty())
        _SocketPtr=new struct sockaddr_in;
    else
        _SocketPtr=new struct sockaddr_un;

    memcpy(_SocketPtr,ctcp._SocketPtr,sizeof(ctcp._SocketPtr));

    _SocketPtrSize=ctcp._SocketPtrSize;
}

netplus::tcp::tcp(const char* uxsocket,int maxconnections,int sockopts) : socket(){
    NetException exception;
@@ -242,6 +253,19 @@ void netplus::tcp::getAddress(std::string &addr){
    addr=ipaddr;
}

netplus::udp::udp(netplus::udp& cudp){
    _Socket=cudp._Socket;
    if(_UxPath.empty())
        _SocketPtr=new struct sockaddr_in;
    else
        _SocketPtr=new struct sockaddr_un;

    memcpy(_SocketPtr,cudp._SocketPtr,sizeof(cudp._SocketPtr));

    _SocketPtrSize=cudp._SocketPtrSize;
}


netplus::udp::udp(const char* uxsocket,int maxconnections,int sockopts) : socket(){
    NetException exception;
    int optval = 1;
+2 −0
Original line number Diff line number Diff line
@@ -63,6 +63,7 @@ namespace netplus {
        
        class tcp : public socket{
        public:
            tcp(netplus::tcp& ctcp);
            tcp(const char *uxsocket,int maxconnections,
                int sockopts);
            tcp(const char *addr,int port,int maxconnections,
@@ -92,6 +93,7 @@ namespace netplus {
        
        class udp : public socket{
        public:
            udp(udp &cudp);
            udp(const char *uxsocket,int maxconnections,
                int sockopts);
            udp(const char *addr,int port,int maxconnections,