proxygen
folly::SocketAddress::ExternalUnixAddr Struct Reference

Public Member Functions

socklen_t pathLength () const
 
void init ()
 
void init (const ExternalUnixAddr &other)
 
void copy (const ExternalUnixAddr &other)
 
void free ()
 

Public Attributes

struct sockaddr_un * addr
 
socklen_t len
 

Detailed Description

Unix socket addresses require more storage than IPv4 and IPv6 addresses, and are comparatively little-used.

Therefore SocketAddress' internal storage_ member variable doesn't contain room for a full unix address, to avoid wasting space in the common case. When we do need to store a Unix socket address, we use this ExternalUnixAddr structure to allocate a struct sockaddr_un separately on the heap.

Definition at line 555 of file SocketAddress.h.

Member Function Documentation

void folly::SocketAddress::ExternalUnixAddr::copy ( const ExternalUnixAddr other)
inline

Definition at line 573 of file SocketAddress.h.

References addr, and len.

Referenced by folly::SocketAddress::operator=().

573  {
574  len = other.len;
575  memcpy(addr, other.addr, size_t(len));
576  }
void folly::SocketAddress::ExternalUnixAddr::init ( )
inline

Definition at line 563 of file SocketAddress.h.

Referenced by folly::SocketAddress::operator=(), and folly::SocketAddress::SocketAddress().

563  {
564  addr = new struct sockaddr_un;
565  addr->sun_family = AF_UNIX;
566  len = 0;
567  }
void folly::SocketAddress::ExternalUnixAddr::init ( const ExternalUnixAddr other)
inline

Definition at line 568 of file SocketAddress.h.

References addr, and len.

568  {
569  addr = new struct sockaddr_un;
570  len = other.len;
571  memcpy(addr, other.addr, size_t(len));
572  }
socklen_t folly::SocketAddress::ExternalUnixAddr::pathLength ( ) const
inline

Definition at line 559 of file SocketAddress.h.

Referenced by folly::SocketAddress::operator<(), and folly::SocketAddress::operator==().

559  {
560  return socklen_t(len - offsetof(struct sockaddr_un, sun_path));
561  }

Member Data Documentation

struct sockaddr_un* folly::SocketAddress::ExternalUnixAddr::addr
socklen_t folly::SocketAddress::ExternalUnixAddr::len

The documentation for this struct was generated from the following file: