/// <summary> /// Connects the specified end point. /// </summary> /// <param name="endPoint">The end point.</param> /// <param name="bufferSize">Size of the buffer.</param> /// <param name="clientStreamFactory">The client stream factory.</param> /// <returns> /// Network Stream instance /// </returns> public NetworkStream Connect(AddressEndPoint endPoint, int bufferSize, IClientStreamFactory clientStreamFactory) { DoDisposeCheck(); if (endPoint == null) { ThrowHelper.ThrowArgumentNullException("endPoint"); } if (bufferSize < 0) { ThrowHelper.ThrowArgumentOutOfRangeException("bufferSize"); } if (clientStreamFactory == null) { ThrowHelper.ThrowArgumentNullException("clientStreamFactory"); } ITcpClient client = mNetworkFactory.CreateTcpClient(); client.Connect(endPoint); // ez dobhat kivételt client.Client.SendBufferSize = bufferSize; client.Client.ReceiveBufferSize = bufferSize; client.Client.SendTimeout = Timeout.Infinite; client.Client.ReceiveTimeout = Timeout.Infinite; client.Client.SetKeepAliveValues(true, DefaultSocketKeepAliveTime, DefaultSocketKeepAliveTimeInterval); client.Client.NoDelay = this.NoDelay; if (LOGGER.IsDebugEnabled) { LOGGER.Debug(string.Format("SYNAPSE_NETWORK_MANAGER, create client network stream for connection. Factory type: '{0}'. Connection remote endpoint: '{1}'", clientStreamFactory.GetType().FullName, endPoint.ToString())); } return(clientStreamFactory.CreateNetworkStream(client)); }
/// <summary> /// Begins the connect. /// </summary> /// <param name="endPoint">The end point.</param> /// <param name="bufferSize">Size of the buffer.</param> /// <param name="clientStreamFactory">The client stream factory.</param> /// <param name="callback">The callback.</param> /// <param name="state">The state.</param> /// <returns>Async property</returns> public IAsyncResult BeginConnect(AddressEndPoint endPoint, int bufferSize, IClientStreamFactory clientStreamFactory, AsyncCallback callback, object state) { DoDisposeCheck(); if (endPoint == null) { ThrowHelper.ThrowArgumentNullException("endPoint"); } if (bufferSize < 0) { ThrowHelper.ThrowArgumentOutOfRangeException("bufferSize"); } if (clientStreamFactory == null) { ThrowHelper.ThrowArgumentNullException("clientStreamFactory"); } Interlocked.Increment(ref mAsyncActiveConnectCount); NetworkManagerConnectDelegate d = new NetworkManagerConnectDelegate(this.Connect); if (this.mAsyncActiveConnectEvent == null) { lock (LOCK_CONNECT) { if (this.mAsyncActiveConnectEvent == null) { this.mAsyncActiveConnectEvent = new AutoResetEvent(true); } } } this.mAsyncActiveConnectEvent.WaitOne(); this.mConnectDelegate = d; return(d.BeginInvoke(endPoint, bufferSize, clientStreamFactory, callback, state)); }
/// <summary> /// Connects the specified end point. /// </summary> /// <param name="endPoint">The end point.</param> /// <param name="clientStreamFactory">The client stream factory.</param> /// <returns>Network Stream instance</returns> public NetworkStream Connect(AddressEndPoint endPoint, IClientStreamFactory clientStreamFactory) { DoDisposeCheck(); return(Connect(endPoint, this.mSocketReceiveBufferSize, clientStreamFactory)); }
/// <summary> /// Begins the connect. /// </summary> /// <param name="endPoint">The end point.</param> /// <param name="clientStreamFactory">The client stream factory.</param> /// <param name="callback">The callback.</param> /// <param name="state">The state.</param> /// <returns>Async property</returns> public IAsyncResult BeginConnect(AddressEndPoint endPoint, IClientStreamFactory clientStreamFactory, AsyncCallback callback, object state) { return(BeginConnect(endPoint, this.mSocketReceiveBufferSize, clientStreamFactory, callback, state)); }