protected bool Activate(object owningObject, bool async, int timeout, GeneralAsyncDelegate asyncCallback) { GlobalLog.Assert(owningObject == Owner || Owner == null, "PooledStream::Activate|Owner is not the same as expected."); try { if (m_Initalizing) { IPAddress address = null; m_AsyncCallback = asyncCallback; Socket socket = ServicePoint.GetConnection(this, owningObject, async, out address, ref m_AbortSocket, ref m_AbortSocket6, timeout); if (socket != null) { m_NetworkStream.InitNetworkStream(socket, FileAccess.ReadWrite); m_ServerAddress = address; m_Initalizing = false; m_JustConnected = true; m_AbortSocket = null; m_AbortSocket6 = null; return(true); } return(false); } else if (async && asyncCallback != null) { asyncCallback(owningObject, this); } return(true); } catch { m_Initalizing = false; throw; } }
protected bool Activate(object owningObject, bool async, GeneralAsyncDelegate asyncCallback) { GlobalLog.Assert(owningObject == Owner || Owner == null, "PooledStream::Activate|Owner is not the same as expected."); try { if (m_Initalizing) { IPAddress address = null; m_AsyncCallback = asyncCallback; Socket socket = ServicePoint.GetConnection(this, owningObject, async, out address, ref m_AbortSocket, ref m_AbortSocket6); if (socket != null) { if (Logging.On) { Logging.PrintInfo(Logging.Web, this, SR.GetString(SR.net_log_socket_connected, socket.LocalEndPoint, socket.RemoteEndPoint)); } m_NetworkStream.InitNetworkStream(socket, FileAccess.ReadWrite); m_ServerAddress = address; m_Initalizing = false; m_JustConnected = true; m_AbortSocket = null; m_AbortSocket6 = null; return(true); } return(false); } else if (async && asyncCallback != null) { asyncCallback(owningObject, this); } return(true); } catch { m_Initalizing = false; throw; } }