O^O Telnet Server源代码星期五 2004 05 28上午 10:16:16
昨天晚上,正在上网,一时精力过剩,想起写一个Telnet Server的想法。结果昨天晚上2个小时,加上今天上午2个小时,一个被我称为O^O的Telnet Server诞生了。
之所以想写它,是因为我想用完全的OO的方法实现Telnet Server,用OO的方法实现非常简单。而O^O Telnet Server这个名字的意思就是OO面向对象的意思,只不过在中间加了个“^”而已。
O^O可以支持多个客户端同时连接,调用CMD.exe实现Shell,暂时只支持2000、xp、2003系列,因为我没有98下的vs.net,所以我也不打算让他支持98。
刚刚完成,bug很多,不管他,先来个0.1的release再说。 呵呵,搞不好是绝版哦,还不看看先! 文件列表: App.ico AssemblyInfo.cs bin mainclass.cs MyTelnetServer.csproj MyTelnetServer.csproj.user MyTelnetServer.sln TelnetCMD.cs TelnetReader.cs TelnetSession.cs TelnetWriter.cs 说明.txt 部分代码: public class TelnetSession { public TelnetSession(TcpClient client) { NetworkStream stream = client.GetStream(); TelnetCMD cmd = new TelnetCMD(); new TelnetReader(stream,cmd); new TelnetWriter(stream,cmd); } }
public class TelnetCMD { Process process1; StreamReader reader1; StreamWriter writer1; StreamReader readerErr1;
public StreamReader ReadStream { get { return reader1; } } public StreamWriter WriterStream { get { return writer1; } } public StreamReader ReadErrStream { get { return readerErr1; } }
public TelnetCMD() { Process process1 = new Process(); process1.StartInfo.UseShellExecute = false; process1.StartInfo.RedirectStandardInput = true; process1.StartInfo.RedirectStandardOutput = true; process1.StartInfo.RedirectStandardError = true; process1.StartInfo.FileName="cmd.exe"; process1.Start(); reader1 = process1.StandardOutput; writer1 = process1.StandardInput; readerErr1 = process1.StandardError; } } http://www.blogcn.com/user9/y97523http://img.win8xp.cn/technique_5/20046720132774471.jpg下载后将扩展名改为rar即可
|