public void StartConnect(ref SelectControl control, Buf safeBuffer) { if (accessorSocket != null) { throw new InvalidOperationException("CodeBug: StartConnect called but socket is not null"); } accessorSocket = new Socket(accessorHost.GetAddressFamilyForTcp(), SocketType.Stream, ProtocolType.Tcp); accessorSocket.Blocking = false; if (accessorHost.proxy != null) { throw new NotImplementedException("accessor host through proxy not implemented"); } accessorHost.targetEndPoint.ForceIPResolution(DnsPriority.IPv4ThenIPv6); connectAsyncArgs.RemoteEndPoint = accessorHost.targetEndPoint.ipEndPoint; Console.WriteLine("{0} Connecting to {1}:{2}", DateTime.Now, accessorHost.targetEndPoint.ipOrHost, accessorHost.targetEndPoint.port); if (accessorSocket.ConnectAsync(connectAsyncArgs)) { control.AddConnectSocket(accessorSocket, ConnectHandler); } else { throw new NotImplementedException("immediate connect not implemented"); } }
public static Socket NewSocketConnection(ref InternetHost host) { Socket socket = new Socket(host.GetAddressFamilyForTcp(), SocketType.Stream, ProtocolType.Tcp); BufStruct dataLeftOverFromProxyConnect = default(BufStruct); host.Connect(socket, DnsPriority.IPv4ThenIPv6, ProxyConnectOptions.None, ref dataLeftOverFromProxyConnect); if (dataLeftOverFromProxyConnect.contentLength > 0) { throw new NotImplementedException(); } return(socket); }