split socket.hpp up in multiple headers to lower build time somewhat

This commit is contained in:
Arvid Norberg 2009-09-16 03:46:36 +00:00
parent 550fb333a2
commit 6c67da08d6
41 changed files with 341 additions and 158 deletions

View File

@ -31,6 +31,7 @@ set(sources
policy
session
session_impl
socket_io
socks5_stream
stat
storage

View File

@ -368,6 +368,7 @@ SOURCES =
policy
session
session_impl
socket_io
socks5_stream
stat
storage

View File

@ -18,6 +18,7 @@ nobase_include_HEADERS = \
ConvertUTF.h \
create_torrent.hpp \
debug.hpp \
deadline_timer.hpp \
disk_buffer_holder.hpp \
disk_io_thread.hpp \
entry.hpp \
@ -67,6 +68,7 @@ nobase_include_HEADERS = \
size_type.hpp \
socket.hpp \
socket_type.hpp \
socket_io.hpp \
socks5_stream.hpp \
ssl_stream.hpp \
stat.hpp \

View File

@ -40,6 +40,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/config.hpp"
#include "libtorrent/assert.hpp"
#include "libtorrent/identify_client.hpp"
#include "libtorrent/socket_io.hpp"
namespace libtorrent
{

View File

@ -77,6 +77,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/assert.hpp"
#include "libtorrent/policy.hpp" // for policy::peer
#include "libtorrent/alert.hpp" // for alert_manager
#include "libtorrent/deadline_timer.hpp"
namespace libtorrent
{

View File

@ -40,10 +40,12 @@ POSSIBILITY OF SUCH DAMAGE.
#endif
#include "libtorrent/socket.hpp"
#include "libtorrent/error_code.hpp"
#include "libtorrent/invariant_check.hpp"
#include "libtorrent/assert.hpp"
#include "libtorrent/bandwidth_limit.hpp"
#include "libtorrent/bandwidth_queue_entry.hpp"
#include "libtorrent/time.hpp"
using boost::intrusive_ptr;

View File

@ -35,6 +35,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/config.hpp"
#include "libtorrent/socket.hpp"
#include "libtorrent/error_code.hpp"
#include <boost/shared_ptr.hpp>
#include <boost/function.hpp>
#include <list>

View File

@ -38,7 +38,8 @@ POSSIBILITY OF SUCH DAMAGE.
#include <boost/noncopyable.hpp>
#include <boost/thread/mutex.hpp>
#include "libtorrent/socket.hpp"
#include "libtorrent/time.hpp"
#include "libtorrent/error_code.hpp"
#include "libtorrent/deadline_timer.hpp"
#ifdef TORRENT_CONNECTION_LOGGING
#include <fstream>

View File

@ -0,0 +1,93 @@
/*
Copyright (c) 2009, Arvid Norberg
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the distribution.
* Neither the name of the author nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef TORRENT_DEADLINE_TIMER_HPP_INCLUDED
#define TORRENT_DEADLINE_TIMER_HPP_INCLUDED
#ifdef __OBJC__
#define Protocol Protocol_
#endif
#if BOOST_VERSION < 103500
#include <asio/basic_deadline_timer.hpp>
#include <asio/time_traits.hpp>
#else
#include <boost/asio/basic_deadline_timer.hpp>
#include <boost/asio/time_traits.hpp>
#endif
#ifdef __OBJC__
#undef Protocol
#endif
#include "libtorrent/time.hpp"
// asio time_traits
#if BOOST_VERSION >= 103500
namespace boost {
#endif
namespace asio
{
template<>
struct time_traits<libtorrent::ptime>
{
typedef libtorrent::ptime time_type;
typedef libtorrent::time_duration duration_type;
static time_type now()
{ return time_type(libtorrent::time_now_hires()); }
static time_type add(time_type t, duration_type d)
{ return time_type(t.time + d.diff);}
static duration_type subtract(time_type t1, time_type t2)
{ return duration_type(t1 - t2); }
static bool less_than(time_type t1, time_type t2)
{ return t1 < t2; }
static boost::posix_time::time_duration to_posix_duration(
duration_type d)
{ return boost::posix_time::microseconds(libtorrent::total_microseconds(d)); }
};
}
#if BOOST_VERSION >= 103500
}
#endif
namespace libtorrent
{
#if BOOST_VERSION < 103500
typedef ::asio::basic_deadline_timer<libtorrent::ptime> deadline_timer;
#else
typedef boost::asio::basic_deadline_timer<libtorrent::ptime> deadline_timer;
#endif
}
#endif // TORRENT_DEADLINE_TIMER_HPP_INCLUDED

View File

@ -35,6 +35,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/config.hpp"
#include "libtorrent/socket.hpp"
#include "libtorrent/error_code.hpp"
namespace libtorrent
{

View File

@ -43,8 +43,9 @@ POSSIBILITY OF SUCH DAMAGE.
#include <string>
#include "libtorrent/socket.hpp"
#include "libtorrent/error_code.hpp"
#include "libtorrent/http_parser.hpp"
#include "libtorrent/time.hpp"
#include "libtorrent/deadline_timer.hpp"
#include "libtorrent/assert.hpp"
#include "libtorrent/socket_type.hpp"
#include "libtorrent/session_settings.hpp"

View File

@ -169,7 +169,7 @@ public:
&& m_state != sam_connecting;
}
void open(proxy_settings const& s, i2p_stream::handler_type const& h);
void close();
void close(error_code&);
char const* session_id() const { return m_session_id.c_str(); }
std::string const& local_endpoint() const { return m_i2p_local_endpoint; }

View File

@ -53,6 +53,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/session_status.hpp"
#include "libtorrent/udp_socket.hpp"
#include "libtorrent/socket.hpp"
#include "libtorrent/deadline_timer.hpp"
namespace libtorrent
{

View File

@ -37,6 +37,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/peer_id.hpp"
#include "libtorrent/broadcast_socket.hpp"
#include "libtorrent/intrusive_ptr_base.hpp"
#include "libtorrent/deadline_timer.hpp"
#include <boost/function.hpp>
#include <boost/noncopyable.hpp>

View File

@ -34,7 +34,9 @@ POSSIBILITY OF SUCH DAMAGE.
#define TORRENT_NATPMP_HPP
#include "libtorrent/socket.hpp"
#include "libtorrent/error_code.hpp"
#include "libtorrent/intrusive_ptr_base.hpp"
#include "libtorrent/deadline_timer.hpp"
#include <boost/function.hpp>
#include <boost/thread/mutex.hpp>

View File

@ -34,6 +34,7 @@ POSSIBILITY OF SUCH DAMAGE.
#define TORRENT_PEER_INFO_HPP_INCLUDED
#include "libtorrent/socket.hpp"
#include "libtorrent/deadline_timer.hpp"
#include "libtorrent/peer_id.hpp"
#include "libtorrent/size_type.hpp"
#include "libtorrent/config.hpp"

View File

@ -35,6 +35,8 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/io.hpp"
#include "libtorrent/socket.hpp"
#include "libtorrent/escape_string.hpp"
#include "libtorrent/error_code.hpp"
#include <boost/bind.hpp>
#include <boost/function.hpp>
#if BOOST_VERSION < 103500

View File

@ -51,31 +51,20 @@ POSSIBILITY OF SUCH DAMAGE.
#include <asio/ip/tcp.hpp>
#include <asio/ip/udp.hpp>
#include <asio/io_service.hpp>
#include <asio/deadline_timer.hpp>
#include <asio/write.hpp>
#include <asio/read.hpp>
#include <asio/time_traits.hpp>
#include <asio/basic_deadline_timer.hpp>
#else
#include <boost/asio/ip/tcp.hpp>
#include <boost/asio/ip/udp.hpp>
#include <boost/asio/io_service.hpp>
#include <boost/asio/deadline_timer.hpp>
#include <boost/asio/write.hpp>
#include <boost/asio/read.hpp>
#include <boost/asio/time_traits.hpp>
#include <boost/asio/basic_deadline_timer.hpp>
#endif
#ifdef __OBJC__
#undef Protocol
#endif
#include "libtorrent/io.hpp"
#include "libtorrent/time.hpp"
#include "libtorrent/error_code.hpp"
#include "libtorrent/escape_string.hpp" // for to_string
#ifdef _MSC_VER
#pragma warning(pop)
#endif
@ -96,7 +85,6 @@ namespace libtorrent
typedef ::asio::ip::udp::socket datagram_socket;
typedef ::asio::ip::tcp::acceptor socket_acceptor;
typedef ::asio::io_service io_service;
typedef ::asio::basic_deadline_timer<libtorrent::ptime> deadline_timer;
#else
using boost::asio::ip::tcp;
using boost::asio::ip::udp;
@ -112,111 +100,8 @@ namespace libtorrent
typedef boost::asio::io_service io_service;
namespace asio = boost::asio;
typedef boost::asio::basic_deadline_timer<libtorrent::ptime> deadline_timer;
#endif
inline std::string print_address(address const& addr)
{
error_code ec;
return addr.to_string(ec);
}
inline std::string print_endpoint(tcp::endpoint const& ep)
{
error_code ec;
std::string ret;
address const& addr = ep.address();
#if TORRENT_USE_IPV6
if (addr.is_v6())
{
ret += '[';
ret += addr.to_string(ec);
ret += ']';
ret += ':';
ret += to_string(ep.port()).elems;
}
else
#endif
{
ret += addr.to_string(ec);
ret += ':';
ret += to_string(ep.port()).elems;
}
return ret;
}
inline std::string print_endpoint(udp::endpoint const& ep)
{
return print_endpoint(tcp::endpoint(ep.address(), ep.port()));
}
namespace detail
{
template<class OutIt>
void write_address(address const& a, OutIt& out)
{
#if TORRENT_USE_IPV6
if (a.is_v4())
{
#endif
write_uint32(a.to_v4().to_ulong(), out);
#if TORRENT_USE_IPV6
}
else if (a.is_v6())
{
address_v6::bytes_type bytes
= a.to_v6().to_bytes();
std::copy(bytes.begin(), bytes.end(), out);
}
#endif
}
template<class InIt>
address read_v4_address(InIt& in)
{
unsigned long ip = read_uint32(in);
return address_v4(ip);
}
#if TORRENT_USE_IPV6
template<class InIt>
address read_v6_address(InIt& in)
{
typedef address_v6::bytes_type bytes_t;
bytes_t bytes;
for (bytes_t::iterator i = bytes.begin()
, end(bytes.end()); i != end; ++i)
*i = read_uint8(in);
return address_v6(bytes);
}
#endif
template<class Endpoint, class OutIt>
void write_endpoint(Endpoint const& e, OutIt& out)
{
write_address(e.address(), out);
write_uint16(e.port(), out);
}
template<class Endpoint, class InIt>
Endpoint read_v4_endpoint(InIt& in)
{
address addr = read_v4_address(in);
int port = read_uint16(in);
return Endpoint(addr, port);
}
#if TORRENT_USE_IPV6
template<class Endpoint, class InIt>
Endpoint read_v6_endpoint(InIt& in)
{
address addr = read_v6_address(in);
int port = read_uint16(in);
return Endpoint(addr, port);
}
#endif
}
#if TORRENT_USE_IPV6
struct v6only
{

View File

@ -0,0 +1,118 @@
/*
Copyright (c) 2009, Arvid Norberg
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the distribution.
* Neither the name of the author nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef TORRENT_SOCKET_IO_HPP_INCLUDED
#define TORRENT_SOCKET_IO_HPP_INCLUDED
#include "libtorrent/socket.hpp"
#include "libtorrent/io.hpp"
#include "libtorrent/error_code.hpp"
#include <string>
namespace libtorrent
{
std::string print_address(address const& addr);
std::string print_endpoint(tcp::endpoint const& ep);
std::string print_endpoint(udp::endpoint const& ep);
namespace detail
{
template<class OutIt>
void write_address(address const& a, OutIt& out)
{
#if TORRENT_USE_IPV6
if (a.is_v4())
{
#endif
write_uint32(a.to_v4().to_ulong(), out);
#if TORRENT_USE_IPV6
}
else if (a.is_v6())
{
address_v6::bytes_type bytes
= a.to_v6().to_bytes();
std::copy(bytes.begin(), bytes.end(), out);
}
#endif
}
template<class InIt>
address read_v4_address(InIt& in)
{
unsigned long ip = read_uint32(in);
return address_v4(ip);
}
#if TORRENT_USE_IPV6
template<class InIt>
address read_v6_address(InIt& in)
{
typedef address_v6::bytes_type bytes_t;
bytes_t bytes;
for (bytes_t::iterator i = bytes.begin()
, end(bytes.end()); i != end; ++i)
*i = read_uint8(in);
return address_v6(bytes);
}
#endif
template<class Endpoint, class OutIt>
void write_endpoint(Endpoint const& e, OutIt& out)
{
write_address(e.address(), out);
write_uint16(e.port(), out);
}
template<class Endpoint, class InIt>
Endpoint read_v4_endpoint(InIt& in)
{
address addr = read_v4_address(in);
int port = read_uint16(in);
return Endpoint(addr, port);
}
#if TORRENT_USE_IPV6
template<class Endpoint, class InIt>
Endpoint read_v6_endpoint(InIt& in)
{
address addr = read_v6_address(in);
int port = read_uint16(in);
return Endpoint(addr, port);
}
#endif
}
}
#endif

View File

@ -34,7 +34,6 @@ POSSIBILITY OF SUCH DAMAGE.
#define TORRENT_STORAGE_HPP_INCLUDE
#include <vector>
#include <bitset>
#ifdef _MSC_VER
#pragma warning(push, 1)

View File

@ -87,11 +87,6 @@ namespace libtorrent
#else // TORRENT_USE_BOOST_DATE_TIME
#if BOOST_VERSION < 103500
#include <asio/time_traits.hpp>
#else
#include <boost/asio/time_traits.hpp>
#endif
#include <boost/cstdint.hpp>
#include "libtorrent/assert.hpp"
@ -166,34 +161,6 @@ namespace libtorrent
boost::int64_t total_microseconds(time_duration td);
}
// asio time_traits
#if BOOST_VERSION >= 103500
namespace boost {
#endif
namespace asio
{
template<>
struct time_traits<libtorrent::ptime>
{
typedef libtorrent::ptime time_type;
typedef libtorrent::time_duration duration_type;
static time_type now()
{ return time_type(libtorrent::time_now_hires()); }
static time_type add(time_type t, duration_type d)
{ return time_type(t.time + d.diff);}
static duration_type subtract(time_type t1, time_type t2)
{ return duration_type(t1 - t2); }
static bool less_than(time_type t1, time_type t2)
{ return t1 < t2; }
static boost::posix_time::time_duration to_posix_duration(
duration_type d)
{ return boost::posix_time::microseconds(libtorrent::total_microseconds(d)); }
};
}
#if BOOST_VERSION >= 103500
}
#endif
#if defined TORRENT_USE_ABSOLUTE_TIME
#include <mach/mach_time.h>

View File

@ -71,6 +71,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/assert.hpp"
#include "libtorrent/bitfield.hpp"
#include "libtorrent/aux_/session_impl.hpp"
#include "libtorrent/deadline_timer.hpp"
namespace libtorrent
{

View File

@ -60,7 +60,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/peer_id.hpp"
#include "libtorrent/peer.hpp"
#include "libtorrent/config.hpp"
#include "libtorrent/time.hpp"
#include "libtorrent/deadline_timer.hpp"
#include "libtorrent/connection_queue.hpp"
#include "libtorrent/intrusive_ptr_base.hpp"

View File

@ -34,8 +34,10 @@ POSSIBILITY OF SUCH DAMAGE.
#define TORRENT_UDP_SOCKET_HPP_INCLUDED
#include "libtorrent/socket.hpp"
#include "libtorrent/error_code.hpp"
#include "libtorrent/session_settings.hpp"
#include "libtorrent/buffer.hpp"
#include "libtorrent/deadline_timer.hpp"
#include <vector>
#include <boost/function.hpp>

View File

@ -34,10 +34,12 @@ POSSIBILITY OF SUCH DAMAGE.
#define TORRENT_UPNP_HPP
#include "libtorrent/socket.hpp"
#include "libtorrent/error_code.hpp"
#include "libtorrent/broadcast_socket.hpp"
#include "libtorrent/http_connection.hpp"
#include "libtorrent/connection_queue.hpp"
#include "libtorrent/intrusive_ptr_base.hpp"
#include "libtorrent/deadline_timer.hpp"
#include <boost/function.hpp>
#include <boost/noncopyable.hpp>

View File

@ -27,6 +27,10 @@
#include <boost/asio/io_service.hpp>
#endif
#include "libtorrent/config.hpp"
#include "libtorrent/error_code.hpp"
#include "libtorrent/assert.hpp"
# define NETWORK_VARIANT_STREAM_LIMIT 5
namespace libtorrent {

View File

@ -62,6 +62,7 @@ libtorrent_rasterbar_la_SOURCES = \
sha1.cpp \
smart_ban.cpp \
socks5_stream.cpp \
socket_io.cpp \
stat.cpp \
storage.cpp \
torrent.cpp \
@ -78,7 +79,6 @@ libtorrent_rasterbar_la_SOURCES = \
$(KADEMLIA_SOURCES) \
$(GEOIP_SOURCES)
#libtorrent_rasterbar_la_LDFLAGS = $(LDFLAGS) -version-info $(INTERFACE_VERSION_INFO)
libtorrent_rasterbar_la_LDFLAGS = -version-info $(INTERFACE_VERSION_INFO)
@ -99,3 +99,4 @@ if WITH_SHIPPED_ZLIB
libtorrent_rasterbar_la_LIBADD += $(top_builddir)/zlib/libzlib.la
AM_CPPFLAGS += -I$(top_srcdir)/zlib
endif

View File

@ -34,6 +34,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/invariant_check.hpp"
#include "libtorrent/connection_queue.hpp"
#include "libtorrent/socket.hpp"
#include "libtorrent/error_code.hpp"
namespace libtorrent
{

View File

@ -35,6 +35,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include <vector>
#include "libtorrent/enum_net.hpp"
#include "libtorrent/broadcast_socket.hpp"
#include "libtorrent/error_code.hpp"
#if BOOST_VERSION < 103500
#include <asio/ip/host_name.hpp>
#else

View File

@ -34,6 +34,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/http_stream.hpp"
#include "libtorrent/escape_string.hpp" // for base64encode
#include "libtorrent/socket_io.hpp"
namespace libtorrent
{

View File

@ -38,6 +38,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/config.hpp"
#include "libtorrent/gzip.hpp"
#include "libtorrent/socket_io.hpp"
#ifdef _MSC_VER
#pragma warning(push, 1)

View File

@ -34,6 +34,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/i2p_stream.hpp"
#include "libtorrent/assert.hpp"
#include "libtorrent/error_code.hpp"
#include <boost/bind.hpp>
@ -74,9 +75,9 @@ namespace libtorrent
i2p_connection::~i2p_connection()
{}
void i2p_connection::close()
void i2p_connection::close(error_code& e)
{
if (m_sam_socket) m_sam_socket->close();
if (m_sam_socket) m_sam_socket->close(e);
}
void i2p_connection::open(proxy_settings const& s, i2p_stream::handler_type const& handler)

View File

@ -50,6 +50,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/aux_/session_impl.hpp"
#include "libtorrent/socket.hpp"
#include "libtorrent/socket_io.hpp"
#include "libtorrent/bencode.hpp"
#include "libtorrent/io.hpp"
#include "libtorrent/version.hpp"

View File

@ -45,6 +45,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/io.hpp"
#include "libtorrent/assert.hpp"
#include "libtorrent/enum_net.hpp"
#include "libtorrent/socket_io.hpp"
using boost::bind;
using namespace libtorrent;

View File

@ -526,8 +526,9 @@ namespace aux {
#endif
// abort the main thread
m_abort = true;
error_code ec;
#if TORRENT_USE_I2P
m_i2p_conn.close();
m_i2p_conn.close(ec);
#endif
m_queued_for_checking.clear();
if (m_lsd) m_lsd->close();
@ -537,7 +538,6 @@ namespace aux {
if (m_dht) m_dht->stop();
m_dht_socket.close();
#endif
error_code ec;
m_timer.cancel(ec);
// close the listen sockets

78
src/socket_io.cpp Normal file
View File

@ -0,0 +1,78 @@
/*
Copyright (c) 2009, Arvid Norberg
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the distribution.
* Neither the name of the author nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
#include <string>
#include "libtorrent/escape_string.hpp"
#include "libtorrent/error_code.hpp"
#include "libtorrent/socket.hpp"
namespace libtorrent
{
std::string print_address(address const& addr)
{
error_code ec;
return addr.to_string(ec);
}
std::string print_endpoint(tcp::endpoint const& ep)
{
error_code ec;
std::string ret;
address const& addr = ep.address();
#if TORRENT_USE_IPV6
if (addr.is_v6())
{
ret += '[';
ret += addr.to_string(ec);
ret += ']';
ret += ':';
ret += to_string(ep.port()).elems;
}
else
#endif
{
ret += addr.to_string(ec);
ret += ':';
ret += to_string(ep.port()).elems;
}
return ret;
}
std::string print_endpoint(udp::endpoint const& ep)
{
return print_endpoint(tcp::endpoint(ep.address(), ep.port()));
}
}

View File

@ -34,6 +34,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/socks5_stream.hpp"
#include "libtorrent/assert.hpp"
#include "libtorrent/socket_io.hpp"
namespace libtorrent
{

View File

@ -30,9 +30,12 @@ POSSIBILITY OF SUCH DAMAGE.
*/
#include "libtorrent/config.hpp"
#include "libtorrent/socket.hpp"
#include "libtorrent/udp_socket.hpp"
#include "libtorrent/connection_queue.hpp"
#include "libtorrent/escape_string.hpp"
#include "libtorrent/socket_io.hpp"
#include <stdlib.h>
#include <boost/bind.hpp>
#include <boost/array.hpp>

View File

@ -33,6 +33,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/pch.hpp"
#include "libtorrent/socket.hpp"
#include "libtorrent/socket_io.hpp"
#include "libtorrent/upnp.hpp"
#include "libtorrent/io.hpp"
#include "libtorrent/parse_url.hpp"

View File

@ -48,6 +48,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/torrent.hpp"
#include "libtorrent/extensions.hpp"
#include "libtorrent/broadcast_socket.hpp"
#include "libtorrent/socket_io.hpp"
#include "libtorrent/extensions/ut_pex.hpp"

View File

@ -34,6 +34,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include <boost/utility.hpp>
#include "test.hpp"
#include "libtorrent/socket_io.hpp"
/*