public override bool Connect() { if (m_InConnecting) { throw new Exception("The socket is connecting, cannot connect again!"); } if (Client != null) { throw new Exception("The socket is connected, you neednt' connect again!"); } //WindowsPhone doesn't have this property #if SILVERLIGHT && !WINDOWS_PHONE m_InConnecting = true; RemoteEndPoint.ConnectAsync(ClientAccessPolicyProtocol, ProcessConnect, null); #else m_RecvingCache = null; m_SafeEvents.Clear(); if (!IsSyncConnect) { m_InConnecting = true; RemoteEndPoint.ConnectAsync(ProcessConnect, null); } else { Socket socket = RemoteEndPoint.ConnectSync(); if (socket == null) { return(false); } SocketAsyncEventArgs e = new SocketAsyncEventArgs(); e.Completed += SocketEventArgsCompleted; Client = socket; OnGetSocket(e); } return(true); #endif }