add InetSocketAddress::IsMatchingType and use it

This commit is contained in:
Mathieu Lacage
2007-07-30 13:55:28 +02:00
parent df7f115415
commit f2084098e2
4 changed files with 13 additions and 0 deletions

View File

@@ -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 ();

View File

@@ -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
{

View File

@@ -64,6 +64,8 @@ public:
*/
void SetIpv4 (Ipv4Address address);
static bool IsMatchingType (const Address &address);
/**
* \returns an Address instance which represents this
* InetSocketAddress instance.

View File

@@ -52,6 +52,7 @@ public:
ERROR_AGAIN,
ERROR_SHUTDOWN,
ERROR_OPNOTSUPP,
ERROR_INVAL,
SOCKET_ERRNO_LAST
};