当前位置: 首页>>代码示例>>C#>>正文


C# EndPoint.Equals方法代码示例

本文整理汇总了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;
 }
开发者ID:IlchishinVlad,项目名称:0x1821mono112poly,代码行数:11,代码来源:ServerSocket.cs

示例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;
        }
开发者ID:GridProtectionAlliance,项目名称:gsf,代码行数:39,代码来源:UdpServer.cs

示例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;
        }
开发者ID:bholl,项目名称:zeroc-ice,代码行数:60,代码来源:Network.cs


注:本文中的System.Net.EndPoint.Equals方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。