public EndConnect ( IAsyncResult asyncResult ) : void | ||
asyncResult | IAsyncResult | |
return | void |
public void EndConnect(IAsyncResult asyncResult)
{
if (NetEventSource.IsEnabled) NetEventSource.Enter(this, asyncResult);
Socket s = Client;
if (s == null)
{
// Dispose nulls out the client socket field.
throw new ObjectDisposedException(GetType().Name);
}
EndConnectCore(s, asyncResult);
_active = true;
if (NetEventSource.IsEnabled) NetEventSource.Exit(this);
}
/// <summary> /// Methode callback appelée lorsque la connexion est effective. /// </summary> /// <param name="result"></param> private void OnConnect(IAsyncResult result) { try { _tcpClient.EndConnect(result); _connected = true; NetworkStream stream = _tcpClient.GetStream(); if (stream != null) { stream.BeginRead(_buffer, 0, _buffer.Length, OnDataReceived, this); if (this.ReferenceDelegate != null) { this.ReferenceDelegate.OnConnect(this); } } } catch (Exception e) { if (this.ReferenceDelegate != null) { this.ReferenceDelegate.OnError(e, this); } } }