java telnet实现的问题
代码如下:
*************************************************************************
package network;
import java.net.Socket;
import java.net.InetAddress;
import java.io.*;
import java.nio.ByteBuffer;
/**
* Created by IntelliJ IDEA.
* User: franck
* Date: 2007-4-25
* Time: 16:57:07
* To change this template use File | Settings | File Templates.
*/
public class test_telnet extends Thread {
Socket s = null;
BufferedReader reader = null;
InputStream in = null;
OutputStream out = null;
BufferedReader usr = null;
PrintWriter writer = null;
request req = null;
String host = null;
int port;
public test_telnet(String host, int port) {
this.host = host;
this.port = port;
}
public void run() {
try {
// String host = "bbs.fudan.edu.cn ";
// s = new Socket(host, 23);
// String host = "ftp.hjenglish.com ";
// s = new Socket(host, 21);
s = new Socket(host, port);
String line = " ";
String usrReply = " ";
//String startStr = "请输入帐号(试用请输入 'guest ', 注册请输入 'new '): ";
usr = new BufferedReader(new InputStreamReader(System.in));
reader = new BufferedReader(new InputStreamReader(s.getInputStream()));
writer = new PrintWriter(new OutputStreamWriter(s.getOutputStream()));
in = s.getInputStream();