From cf9215deec2d814d641d5e31b311c9e0c3774d9a Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Thu, 1 Jan 2004 21:25:59 +0000 Subject: [PATCH] Made the socket.hpp platform independent --- include/libtorrent/socket.hpp | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/include/libtorrent/socket.hpp b/include/libtorrent/socket.hpp index 493d74e6e..d5761c977 100755 --- a/include/libtorrent/socket.hpp +++ b/include/libtorrent/socket.hpp @@ -30,8 +30,8 @@ POSSIBILITY OF SUCH DAMAGE. */ -#ifndef TORRENT_SOCKET_WIN_HPP_INCLUDED -#define TORRENT_SOCKET_WIN_HPP_INCLUDED +#ifndef TORRENT_SOCKET_HPP_INCLUDED +#define TORRENT_SOCKET_HPP_INCLUDED // TODO: remove the dependency of // platform specific headers here. @@ -77,23 +77,34 @@ namespace libtorrent friend class socket; public: address(); - address(unsigned char a, unsigned char b, unsigned char c, unsigned char d, unsigned short port); + address( + unsigned char a + , unsigned char b + , unsigned char c + , unsigned char d + , unsigned short port); + address(unsigned int addr, unsigned short port); + address(const std::string& addr, unsigned short port); address(const address& a); ~address(); std::string as_string() const; - unsigned int ip() const { return m_sockaddr.sin_addr.s_addr; } - unsigned short port() const { return htons(m_sockaddr.sin_port); } + unsigned int ip() const { return m_ip; } + unsigned short port() const { return m_port; } - bool operator<(const address& a) const { if (ip() == a.ip()) return port() < a.port(); else return ip() < a.ip(); } - bool operator!=(const address& a) const { return (ip() != a.ip()) || port() != a.port(); } - bool operator==(const address& a) const { return (ip() == a.ip()) && port() == a.port(); } + bool operator<(const address& a) const + { if (ip() == a.ip()) return port() < a.port(); else return ip() < a.ip(); } + bool operator!=(const address& a) const + { return (ip() != a.ip()) || port() != a.port(); } + bool operator==(const address& a) const + { return (ip() == a.ip()) && port() == a.port(); } private: - sockaddr_in m_sockaddr; + unsigned int m_ip; + unsigned short m_port; }; class socket: public boost::noncopyable @@ -248,4 +259,5 @@ namespace libtorrent } -#endif // TORRENT_SOCKET_WIN_HPP_INCLUDED +#endif // TORRENT_SOCKET_WIN_INCLUDED +