static Int32 Main(string[] args) { TelnetOptions optionsParser = new TelnetOptions(); List <String> nonOptionArgs = optionsParser.Parse(args); if (nonOptionArgs.Count != 1) { Console.WriteLine("Expected 1 argument but got {0}", nonOptionArgs.Count); optionsParser.PrintUsage(); return(-1); } InternetHost?serverHost; if (nonOptionArgs.Count == 1) { String connectorString = nonOptionArgs[0]; Proxy proxy; String ipOrHostOptionalPort = Proxy.StripAndParseProxies(connectorString, DnsPriority.IPv4ThenIPv6, out proxy); UInt16 port = DefaultPort; String ipOrHost = EndPoints.SplitIPOrHostAndOptionalPort(ipOrHostOptionalPort, ref port); serverHost = new InternetHost(ipOrHost, port, DnsPriority.IPv4ThenIPv6, proxy); } else { serverHost = null; } TelnetClient client = new TelnetClient(optionsParser.wantServerEcho.set, !optionsParser.disableColorDecoding.set); Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); if (serverHost != null) { BufStruct leftOver = default(BufStruct); socket.Connect(serverHost.Value, DnsPriority.IPv4ThenIPv6, ProxyConnectOptions.None, ref leftOver); if (leftOver.contentLength > 0) { Console.WriteLine(Encoding.UTF8.GetString(leftOver.buf, 0, (int)leftOver.contentLength)); } } client.Run(socket); return(0); }
public ConsolePrintCallback(TelnetClient client, TelnetStream stream) { this.client = client; this.stream = stream; }