[ 
https://issues.apache.org/jira/browse/MESOS-1916?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Evelina Dumitrescu closed MESOS-1916.
-------------------------------------
    Resolution: Won't Fix

> 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)

Reply via email to