本文整理汇总了C#中System.Net.EndPoint.ConnectAsync方法的典型用法代码示例。如果您正苦于以下问题:C# EndPoint.ConnectAsync方法的具体用法?C# EndPoint.ConnectAsync怎么用?C# EndPoint.ConnectAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Net.EndPoint
的用法示例。
在下文中一共展示了EndPoint.ConnectAsync方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Connect
public override void Connect(EndPoint remoteEndPoint)
{
if (remoteEndPoint == null)
throw new ArgumentNullException("remoteEndPoint");
if (m_InConnecting)
throw new Exception("The socket is connecting, cannot connect again!");
if (Client != null)
throw new Exception("The socket is connected, you needn't connect again!");
//If there is a proxy set, connect the proxy server by proxy connector
if (Proxy != null)
{
Proxy.Completed += new EventHandler<ProxyEventArgs>(Proxy_Completed);
Proxy.Connect(RemoteEndPoint);
m_InConnecting = true;
return;
}
m_InConnecting = true;
//WindowsPhone doesn't have this property
#if SILVERLIGHT && !WINDOWS_PHONE
remoteEndPoint.ConnectAsync(ClientAccessPolicyProtocol, ProcessConnect, null);
#elif WINDOWS_PHONE
remoteEndPoint.ConnectAsync(ProcessConnect, null);
#else
remoteEndPoint.ConnectAsync(LocalEndPoint, ProcessConnect, null);
#endif
}