本文整理汇总了C#中IPEndPoint.Equals方法的典型用法代码示例。如果您正苦于以下问题:C# IPEndPoint.Equals方法的具体用法?C# IPEndPoint.Equals怎么用?C# IPEndPoint.Equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IPEndPoint
的用法示例。
在下文中一共展示了IPEndPoint.Equals方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Send
public void Send(byte[] dgram, int bytes, IPEndPoint endPoint)
{
//lock (locker)
//{
if (isConnected)
{
if (!endPoint.Equals(udpClient.Client.RemoteEndPoint))
throw new CommunicationException("Attempted to send UDP packet to an endPoint other than that to which this UDP client is specifically connected.");
else
udpClient.Send(dgram, bytes);
}
else
udpClient.Send(dgram, bytes, endPoint);
//}
}
示例2: Equals_Compare_Success
public static void Equals_Compare_Success()
{
IPEndPoint ep = new IPEndPoint(testIpV41, 500);
IPEndPoint ep1 = new IPEndPoint(testIpV41, 500);
IPEndPoint ep2 = new IPEndPoint(testIpV41, 700);
IPEndPoint ep3 = new IPEndPoint(IPAddress.Parse("192.168.0.9"), 700);
Assert.False(ep.Equals(null));
Assert.True(ep.Equals(ep1));
Assert.True(ep.GetHashCode().Equals(ep1.GetHashCode()));
Assert.True(ep1.Equals(ep));
Assert.False(ep.Equals(ep2));
Assert.False(ep.GetHashCode().Equals(ep2.GetHashCode()));
Assert.False(ep2.Equals(ep3));
Assert.False(ep2.GetHashCode().Equals(ep3.GetHashCode()));
}