[java]代码库
/**
* telnet 登陆到服务器
*/
public void telnet() {
System.out.println("Connecting to telnet server " + "127.0.0.1" + ": "
+ "80");
try {
socket = new Socket("127.0.0.1", 80);
// 将socket的输入端数据(来自服务器端)流向本地标准输出,即接收数据
receivePipe = new Pipe(socket.getInputStream(), System.out);
receivePipe.start();
// 将本地的标准输入数据流向socket的输出端,即流向服务器端,发送数据
sendPipe = new Pipe(System.in, socket.getOutputStream());
sendPipe.start();
} catch (IOException e) {
System.out.println("连接失败:" + e);
return;
}
System.out.println("连接成功");
}