#define MSP_NET_SOCKADDR_H_
#include <string>
-#ifndef WIN32
-#include <sys/socket.h>
-#endif
#include "constants.h"
namespace Msp {
class SockAddr
{
public:
- virtual Family get_family() const = 0;
- virtual std::string str() const = 0;
-
- /**
- Fills the given struct sockaddr with information from this SockAddr.
+ struct SysAddr;
- @return Number of bytes used
- */
- virtual unsigned fill_sockaddr(sockaddr &) const = 0;
- virtual unsigned fill_sockaddr(sockaddr_storage &) const;
+protected:
+ SockAddr() { }
+public:
+ virtual ~SockAddr() { }
- virtual SockAddr *copy() const =0;
+ virtual SockAddr *copy() const = 0;
- virtual ~SockAddr() { }
+ static SockAddr *from_sys(const SysAddr &);
+ virtual SysAddr to_sys() const = 0;
- static SockAddr *create(const sockaddr &sa) { return create(reinterpret_cast<const sockaddr_storage &>(sa)); }
- static SockAddr *create(const sockaddr_storage &);
-protected:
- SockAddr() { }
+ virtual Family get_family() const = 0;
+ virtual std::string str() const = 0;
};
} // namespace Net