internal override IAsyncResult BeginBind(SocketBase baseSocket, AsyncCallback callback, object state) { base.CheckDisposed(); Bind_SO d_so = new Bind_SO(callback, state); try { IPEndPoint localEndPoint = (IPEndPoint)baseSocket.SystemSocket.LocalEndPoint; localEndPoint.Port = 0; base._socket.Bind(localEndPoint); } catch (Exception exception) { d_so.Exception = exception; } d_so.SetCompleted(); return(d_so); }
override internal IAsyncResult BeginBind(SocketBase baseSocket, AsyncCallback callback, object state) { CheckDisposed(); Bind_SO stateObj = new Bind_SO(callback, state); try { IPEndPoint ep = (IPEndPoint)baseSocket.SystemSocket.LocalEndPoint; ep.Port = 0; _socket.Bind(ep); } catch (Exception e) { stateObj.Exception = e; } stateObj.SetCompleted(); return(stateObj); }
internal override IAsyncResult BeginBind(SocketBase baseSocket, AsyncCallback callback, object state) { base.CheckDisposed(); if (baseSocket == null) { throw new ArgumentNullException("baseSocket", "The value cannot be null"); } Bind_SO d_so = null; this.SetProgress(true); try { d_so = new Bind_SO((Socket_Socks5)baseSocket, callback, state); SocketBase.BeginGetHostByName(base._proxyServer, new AsyncCallback(this.Bind_GetHost_End), d_so); } catch (Exception exception) { this.SetProgress(false); throw exception; } return(d_so); }
private void Bind_GetHost_End(IAsyncResult ar) { Bind_SO asyncState = (Bind_SO)ar.AsyncState; try { asyncState.UpdateContext(); IPHostEntry host = SocketBase.EndGetHostByName(ar); if (host == null) { throw new SocketException(0x2af9); } IPEndPoint remoteEP = SocketBase.ConstructEndPoint(host, base._proxyPort); asyncState.ProxyIP = remoteEP.Address; base._socket.BeginConnect(remoteEP, new AsyncCallback(this.Bind_Connect_End), asyncState); } catch (Exception exception) { asyncState.Exception = exception; asyncState.SetCompleted(); } }
void Bind_Write_End(IAsyncResult ar) { Bind_SO stateObj = (Bind_SO)ar.AsyncState; try { stateObj.UpdateContext(); NStream.EndWrite(ar); //------------------------------------ // Read the response from proxy server. // NStream.BeginRead(_response, 0, 8, new AsyncCallback(Bind_Read_End), stateObj); } catch (Exception e) { stateObj.Exception = e; stateObj.SetCompleted(); } }
void Bind_Read_End(IAsyncResult ar) { Bind_SO stateObj = (Bind_SO)ar.AsyncState; try { stateObj.UpdateContext(); int num = NStream.EndRead(ar); stateObj.ReadBytes += num; if (stateObj.ReadBytes < 8) { //------------------------------------ // Read the response from proxy server. // NStream.BeginRead( _response, stateObj.ReadBytes, 8 - stateObj.ReadBytes, new AsyncCallback(Bind_Read_End), stateObj); } else { VerifyResponse(); _localEndPoint = ConstructBindEndPoint(stateObj.ProxyIP); _remoteEndPoint = null; stateObj.SetCompleted(); } } catch (Exception e) { stateObj.Exception = e; stateObj.SetCompleted(); } }
override internal IAsyncResult BeginBind( SocketBase baseSocket, AsyncCallback callback, object state) { CheckDisposed(); if(null == baseSocket) throw new ArgumentNullException("baseSocket", "The value cannot be null"); Bind_SO stateObj = null; SetProgress(true); try { stateObj = new Bind_SO((Socket_Socks4a)baseSocket, callback, state); //------------------------------------ // Get end point for the proxy server // BeginGetHostByName( _proxyServer, new AsyncCallback(Bind_GetHost_End), stateObj); } catch(Exception ex) { SetProgress(false); throw ex; } return stateObj; }
override internal IAsyncResult BeginBind(SocketBase baseSocket, AsyncCallback callback, object state) { CheckDisposed(); Bind_SO stateObj = new Bind_SO(callback, state); try { IPEndPoint ep = (IPEndPoint)baseSocket.SystemSocket.LocalEndPoint; ep.Port = 0; _socket.Bind(ep); } catch(Exception e) { stateObj.Exception = e; } stateObj.SetCompleted(); return stateObj; }
override internal IAsyncResult BeginBind(SocketBase baseSocket, AsyncCallback callback, object state) { CheckDisposed(); Bind_SO stateObj = null; SetProgress(true); try { stateObj = new Bind_SO(baseSocket, callback, state); //------------------------------------ // Get end point for the proxy server // BeginGetHostByName(_proxyServer, new AsyncCallback(Bind_GetHost_End), stateObj); } catch(Exception ex) { SetProgress(false); throw ex; } return stateObj; }