Skip to content

Commit

Permalink
完善套接字头文件
Browse files Browse the repository at this point in the history
  • Loading branch information
HEYAHONG committed Sep 16, 2024
1 parent 6f4cd50 commit 3ca37cf
Showing 1 changed file with 71 additions and 0 deletions.
71 changes: 71 additions & 0 deletions hcppbox/HCPPSocket.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,25 @@ class HCPPSocketAddressAuto
{

}

HCPPSocketAddressAuto & operator =(HCPPSocketAddressAuto &oths)
{
if(&oths!=this)
{
addr=oths.addr;
}
return *this;
}

HCPPSocketAddressAuto & operator =(HCPPSocketAddressAuto &&oths)
{
if(&oths!=this)
{
addr=oths.addr;
}
return *this;
}

virtual ~HCPPSocketAddressAuto()
{

Expand All @@ -192,6 +211,19 @@ class HCPPSocketAddressAuto
{
return (HCPPSocketAddress *)(void *)addr.pad;
}

HCPPSocketAddressAuto(HCPPSocketAddress &_addr)
{
memset(&addr,0,sizeof(addr));
memcpy(&addr,&_addr,sizeof(_addr));
}

HCPPSocketAddressAuto(HCPPSocketAddress &&_addr)
{
memset(&addr,0,sizeof(addr));
memcpy(&addr,&_addr,sizeof(_addr));
}

#ifdef HCPPSOCKET_HAVE_SOCKET_IPV4
operator HCPPSocketAddressIPV4 *()
{
Expand All @@ -204,6 +236,19 @@ class HCPPSocketAddressAuto
return NULL;
}
}

HCPPSocketAddressAuto(HCPPSocketAddressIPV4 &_addr)
{
memset(&addr,0,sizeof(addr));
memcpy(&addr,&_addr,sizeof(_addr));
}

HCPPSocketAddressAuto(HCPPSocketAddressIPV4 &&_addr)
{
memset(&addr,0,sizeof(addr));
memcpy(&addr,&_addr,sizeof(_addr));
}

#endif

#ifdef HCPPSOCKET_HAVE_SOCKET_IPV6
Expand All @@ -218,6 +263,19 @@ class HCPPSocketAddressAuto
return NULL;
}
}

HCPPSocketAddressAuto(HCPPSocketAddressIPV6 &_addr)
{
memset(&addr,0,sizeof(addr));
memcpy(&addr,&_addr,sizeof(_addr));
}

HCPPSocketAddressAuto(HCPPSocketAddressIPV6 &&_addr)
{
memset(&addr,0,sizeof(addr));
memcpy(&addr,&_addr,sizeof(_addr));
}

#endif

#ifdef HCPPSOCKET_HAVE_SOCKET_UNIX
Expand All @@ -232,6 +290,19 @@ class HCPPSocketAddressAuto
return NULL;
}
}

HCPPSocketAddressAuto(HCPPSocketAddressUNIX &_addr)
{
memset(&addr,0,sizeof(addr));
memcpy(&addr,&_addr,sizeof(_addr));
}

HCPPSocketAddressAuto(HCPPSocketAddressUNIX &&_addr)
{
memset(&addr,0,sizeof(addr));
memcpy(&addr,&_addr,sizeof(_addr));
}

#endif

HCPPSocketAddressLength Length()
Expand Down

0 comments on commit 3ca37cf

Please sign in to comment.