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
}