You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@mesos.apache.org by "Dominic Hamon (JIRA)" <ji...@apache.org> on 2014/10/14 19:01:33 UTC
[jira] [Created] (MESOS-1916) Create utility class for storing
sockaddr
Dominic Hamon created MESOS-1916:
------------------------------------
Summary: Create utility class for storing sockaddr
Key: MESOS-1916
URL: https://issues.apache.org/jira/browse/MESOS-1916
Project: Mesos
Issue Type: Task
Components: libprocess
Reporter: Dominic Hamon
Assignee: Evelina Dumitrescu
Priority: Minor
{noformat}
// Convenience struct for when you need a |struct sockaddr|.
struct SockaddrStorage {
SockaddrStorage() : addr_len(sizeof(addr_storage)),
addr(reinterpret_cast<struct sockaddr*>(&addr_storage)) {}
SockaddrStorage(const SockaddrStorage& other);
void operator=(const SockaddrStorage& other);
struct sockaddr_storage addr_storage;
socklen_t addr_len;
struct sockaddr* const addr;
};
SockaddrStorage::SockaddrStorage(const SockaddrStorage& other)
: addr_len(other.addr_len),
addr(reinterpret_cast<struct sockaddr*>(&addr_storage)) {
memcpy(addr, other.addr, addr_len);
}
void SockaddrStorage::operator=(const SockaddrStorage& other) {
addr_len = other.addr_len;
// addr is already set to &this->addr_storage by default ctor.
memcpy(addr, other.addr, addr_len);
}
{noformat}
(shamelessly borrowed from http://src.chromium.org/svn/trunk/src/net/base/net_util.h/cc)
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)