本文整理汇总了C#中System.Net.EndPoint.Equals方法的典型用法代码示例。如果您正苦于以下问题:C# EndPoint.Equals方法的具体用法?C# EndPoint.Equals怎么用?C# EndPoint.Equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Net.EndPoint
的用法示例。
在下文中一共展示了EndPoint.Equals方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: getClientsPosition
private int getClientsPosition(EndPoint remoteEndPoint)
{
for (int i = 0; i < clientList.Count; i++)
{
if (remoteEndPoint.Equals(clientList[i].IPAddress))
{
return i;
}
}
return -1;
}
示例2: IdentifyClient
private TransportProvider<EndPoint> IdentifyClient(EndPoint remoteEndPoint)
{
IPEndPoint remoteIPEndPoint = remoteEndPoint as IPEndPoint;
IPEndPoint clientIPEndPoint;
foreach (TransportProvider<EndPoint> client in m_clientInfoLookup.Values.Select(clientInfo => clientInfo.Client))
{
clientIPEndPoint = client.Provider as IPEndPoint;
switch (m_clientIdentificationMode)
{
case ClientIdentificationMode.IP:
if ((object)remoteIPEndPoint != null && (object)clientIPEndPoint != null)
{
if (remoteIPEndPoint.Address.Equals(clientIPEndPoint.Address))
return client;
}
break;
case ClientIdentificationMode.Port:
if ((object)remoteIPEndPoint != null && (object)clientIPEndPoint != null)
{
if (remoteIPEndPoint.Port == clientIPEndPoint.Port)
return client;
}
break;
case ClientIdentificationMode.EndPoint:
if (remoteEndPoint.Equals(client.Provider))
return client;
break;
}
}
return null;
}
示例3: doConnect
public static bool doConnect(Socket fd, EndPoint addr)
{
repeatConnect:
try
{
//
// Even though we are on the client side, the call to Bind()
// is necessary to work around a .NET bug: if a socket is
// connected non-blocking, the LocalEndPoint and RemoteEndPoint
// properties are null. The call to Bind() fixes this.
//
IPAddress any = fd.AddressFamily == AddressFamily.InterNetworkV6 ? IPAddress.IPv6Any : IPAddress.Any;
fd.Bind(new IPEndPoint(any, 0));
IAsyncResult result = fd.BeginConnect(addr, null, null);
if(!result.CompletedSynchronously)
{
return false;
}
fd.EndConnect(result);
}
catch(SocketException ex)
{
if(interrupted(ex))
{
goto repeatConnect;
}
closeSocketNoThrow(fd);
if(connectionRefused(ex))
{
throw new Ice.ConnectionRefusedException(ex);
}
else
{
throw new Ice.ConnectFailedException(ex);
}
}
//
// On Windows, we need to set the socket's blocking status again
// after the asynchronous connect. Seems like a bug in .NET.
//
setBlock(fd, fd.Blocking);
if(AssemblyUtil.platform_ == AssemblyUtil.Platform.NonWindows)
{
//
// Prevent self connect (self connect happens on Linux when a client tries to connect to
// a server which was just deactivated if the client socket re-uses the same ephemeral
// port as the server).
//
if(addr.Equals(getLocalAddress(fd)))
{
throw new Ice.ConnectionRefusedException();
}
}
return true;
}