added +int Socket::bindToIfceAddr()
This commit is contained in:
parent
05c2905a0a
commit
d3ed032636
@ -76,10 +76,17 @@ public:
|
||||
|
||||
int shutdown (int how = 2) QSE_CPP_NOEXCEPT;
|
||||
int connect (const SocketAddress& target) QSE_CPP_NOEXCEPT;
|
||||
|
||||
int bind (const SocketAddress& target) QSE_CPP_NOEXCEPT;
|
||||
// bind to the ip address of the interface
|
||||
int bindToIfceAddr (const qse_mchar_t* ifce, qse_uint16_t port) QSE_CPP_NOEXCEPT;
|
||||
// bind to the ip address of the interface
|
||||
int bindToIfceAddr (const qse_wchar_t* ifce, qse_uint16_t port) QSE_CPP_NOEXCEPT;
|
||||
|
||||
int listen (int backlog = 128) QSE_CPP_NOEXCEPT;
|
||||
int accept (Socket* newsck, SocketAddress* newaddr, int traits = 0) QSE_CPP_NOEXCEPT;
|
||||
|
||||
|
||||
// The send() functions sends data by attemping a single call to the
|
||||
// underlying system calls
|
||||
qse_ssize_t send (const void* buf, qse_size_t len) QSE_CPP_NOEXCEPT;
|
||||
|
@ -66,6 +66,7 @@ public:
|
||||
|
||||
void setIpaddr (const qse_ip4ad_t* ipaddr) QSE_CPP_NOEXCEPT;
|
||||
void setIpaddr (const qse_ip6ad_t* ipaddr) QSE_CPP_NOEXCEPT;
|
||||
void setIpaddr (qse_uint32_t ipaddr) QSE_CPP_NOEXCEPT;
|
||||
|
||||
const qse_ip4ad_t* getIp4addr () const QSE_CPP_NOEXCEPT;
|
||||
const qse_ip6ad_t* getIp6addr () const QSE_CPP_NOEXCEPT;
|
||||
|
@ -308,6 +308,20 @@ int Socket::bind (const SocketAddress& target) QSE_CPP_NOEXCEPT
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Socket::bindToIfceAddr (const qse_mchar_t* ifce, qse_uint16_t port) QSE_CPP_NOEXCEPT
|
||||
{
|
||||
SocketAddress addr;
|
||||
if (this->getIfceAddress(ifce, &addr) <= -1) return -1;
|
||||
return this->bind(addr);
|
||||
}
|
||||
|
||||
int Socket::bindToIfceAddr (const qse_wchar_t* ifce, qse_uint16_t port) QSE_CPP_NOEXCEPT
|
||||
{
|
||||
SocketAddress addr;
|
||||
if (this->getIfceAddress(ifce, &addr) <= -1) return -1;
|
||||
return this->bind(addr);
|
||||
}
|
||||
|
||||
int Socket::listen (int backlog) QSE_CPP_NOEXCEPT
|
||||
{
|
||||
QSE_ASSERT (this->handle != QSE_INVALID_SCKHND);
|
||||
|
@ -85,6 +85,7 @@
|
||||
# define FAMILY(x) (-1)
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
/////////////////////////////////
|
||||
QSE_BEGIN_NAMESPACE(QSE)
|
||||
/////////////////////////////////
|
||||
@ -128,6 +129,17 @@ void SocketAddress::setIpaddr (const qse_ip4ad_t* ipaddr) QSE_CPP_NOEXCEPT
|
||||
#endif
|
||||
}
|
||||
|
||||
void SocketAddress::setIpaddr (const qse_uint32_t ipaddr) QSE_CPP_NOEXCEPT
|
||||
{
|
||||
#if defined(AF_INET)
|
||||
if (FAMILY(&this->skad) == AF_INET)
|
||||
{
|
||||
struct sockaddr_in* v4 = (struct sockaddr_in*)&this->skad;
|
||||
v4->sin_addr.s_addr = ipaddr;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void SocketAddress::setIpaddr (const qse_ip6ad_t* ipaddr) QSE_CPP_NOEXCEPT
|
||||
{
|
||||
#if defined(AF_INET6)
|
||||
|
Loading…
Reference in New Issue
Block a user