/// <summary> /// Begins an asynchronous request for a remote host connection. /// </summary> /// <param name="host">The host address to connect to.</param> /// <param name="port">The port number to connect to.</param> /// <param name="callback">The <see cref="T:System.AsyncCallback" /> delegate.</param> /// <param name="state">An object that contains state information for this request.</param> /// <returns> /// An <see cref="T:System.IAsyncResult" /> that references the asynchronous connection. /// </returns> public new IAsyncResult BeginConnect(string host, int port, AsyncCallback callback, object state) { if (host == null) { throw new ArgumentNullException("host"); } if (callback == null) { throw new ArgumentNullException("callback"); } connectCallback = callback; if (proxyAddress == null || proxyPort == -1) { return(BeginDNSResolve(host, port, callback, state)); } else { processor = new Socks5Processor(this); asyncResult = processor.BeginProcessing(host, port, OnConnectionEstablished); return(asyncResult); } }
/// <summary> /// Begins an asynchronous request for a remote host connection. /// </summary> /// <param name="remoteEP">An <see cref="T:System.Net.EndPoint" /> that represents the remote host.</param> /// <param name="callback">The <see cref="T:System.AsyncCallback" /> delegate.</param> /// <param name="state">An object that contains state information for this request.</param> /// <returns> /// An <see cref="T:System.IAsyncResult" /> that references the asynchronous connection. /// </returns> /// <PermissionSet> /// <IPermission class="System.Security.Permissions.EnvironmentPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" /> /// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" /> /// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" /> /// <IPermission class="System.Diagnostics.PerformanceCounterPermission, System, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" /> /// <IPermission class="System.Net.SocketPermission, System, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" /> /// </PermissionSet> public new IAsyncResult BeginConnect(EndPoint remoteEP, AsyncCallback callback, object state) { if (remoteEP == null) { throw new ArgumentNullException("remoteEP"); } if (callback == null) { throw new ArgumentNullException("callback"); } if (proxyAddress == null || proxyPort == -1) { return(base.BeginConnect(remoteEP, callback, state)); } else { connectCallback = callback; processor = new Socks5Processor(this); asyncResult = processor.BeginProcessing((IPEndPoint)remoteEP, OnConnectionEstablished); return(asyncResult); } }
/// <summary> /// Establishes a connection to a remote host. /// </summary> /// <param name="remoteEP">An <see cref="T:System.Net.EndPoint" /> that represents the remote device.</param> /// <PermissionSet> /// <IPermission class="System.Security.Permissions.EnvironmentPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" /> /// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" /> /// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" /> /// <IPermission class="System.Diagnostics.PerformanceCounterPermission, System, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" /> /// <IPermission class="System.Net.SocketPermission, System, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" /> /// </PermissionSet> public new void Connect(EndPoint remoteEP) { if (remoteEP == null) { throw new ArgumentNullException("remoteEP"); } if (proxyAddress == null || proxyPort == -1) { base.Connect(remoteEP); } else { processor = new Socks5Processor(this); asyncResult = processor.BeginProcessing((IPEndPoint)remoteEP, OnConnectionEstablished); asyncResult.AsyncWaitHandle.WaitOne(); } }