* Changed to using sockaddr* in libtorrent's api.

* Prepared SocketManager for inclusion in the api.

* From <nornagon@gmail.com>: bound some control keys in text input.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@650 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
rakshasa
2006-03-15 16:22:40 +00:00
parent 2863c10389
commit 571fe8b2f4
9 changed files with 138 additions and 27 deletions
+16
View File
@@ -90,6 +90,8 @@ public:
bool set_address_str(const std::string& a) { return set_address_c_str(a.c_str()); }
bool set_address_c_str(const char* a);
uint32_t length() const;
socket_address_inet* sa_inet() { return reinterpret_cast<socket_address_inet*>(this); }
socket_address_inet6* sa_inet6() { return reinterpret_cast<socket_address_inet6*>(this); }
@@ -109,6 +111,9 @@ public:
// struct.
void copy(const socket_address& src, size_t length);
static socket_address* cast_from(sockaddr* sa) { return reinterpret_cast<socket_address*>(sa); }
static const socket_address* cast_from(const sockaddr* sa) { return reinterpret_cast<const socket_address*>(sa); }
// The different families will be sorted according to the
// sa_family_t's numeric value.
bool operator == (const socket_address& rhs) const;
@@ -254,6 +259,17 @@ socket_address::set_address_c_str(const char* a) {
}
}
// Is the zero length really needed, should we require some length?
inline uint32_t
socket_address::length() const {
switch(family()) {
case af_inet:
return sizeof(sockaddr_in);
default:
return 0;
}
}
inline void
socket_address::copy(const socket_address& src, size_t length) {
length = std::min(length, sizeof(socket_address));