add InetSocketAddress::IsMatchingType and use it
This commit is contained in:
@@ -91,6 +91,10 @@ UdpSocket::Bind (void)
|
||||
int
|
||||
UdpSocket::Bind (const Address &address)
|
||||
{
|
||||
if (!InetSocketAddress::IsMatchingType (address))
|
||||
{
|
||||
return ERROR_INVAL;
|
||||
}
|
||||
InetSocketAddress transport = InetSocketAddress::ConvertFrom (address);
|
||||
Ipv4Address ipv4 = transport.GetIpv4 ();
|
||||
uint16_t port = transport.GetPort ();
|
||||
|
||||
@@ -45,6 +45,12 @@ InetSocketAddress::SetIpv4 (Ipv4Address address)
|
||||
m_ipv4 = address;
|
||||
}
|
||||
|
||||
bool
|
||||
InetSocketAddress::IsMatchingType (const Address &address)
|
||||
{
|
||||
return address.CheckCompatible (GetType (), 6);
|
||||
}
|
||||
|
||||
Address
|
||||
InetSocketAddress::ConvertTo (void) const
|
||||
{
|
||||
|
||||
@@ -64,6 +64,8 @@ public:
|
||||
*/
|
||||
void SetIpv4 (Ipv4Address address);
|
||||
|
||||
static bool IsMatchingType (const Address &address);
|
||||
|
||||
/**
|
||||
* \returns an Address instance which represents this
|
||||
* InetSocketAddress instance.
|
||||
|
||||
@@ -52,6 +52,7 @@ public:
|
||||
ERROR_AGAIN,
|
||||
ERROR_SHUTDOWN,
|
||||
ERROR_OPNOTSUPP,
|
||||
ERROR_INVAL,
|
||||
SOCKET_ERRNO_LAST
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user