?? telnet.java
字號:
import java.net.*;
import java.io.*;
/* Protocol : Client ----------- Server
*
* <--------- <path> (single line)
* (single line) <cmd> ---------->
* <--------- <output> (several lines)
* <--------- ==end== (single line)
*
* another session started again
*
* <--------- <path> (single line)
* .....
*/
public class Telnet {
static int port = 23;
static final String endMsg = "==end==";
public static void main(String[] args) throws Exception {
if (args[0].equals("server"))
runServer();
else if (args[0].equals("client"))
runClient(args[1], port);
else
System.out.println("Client : java Telnet client ip\r\n"+
"Server : java Telnet server");
}
public static void runClient(String host, int port) throws Exception {
System.out.println("Host " + host + "; port " + port);
Socket socket = new Socket(host, port);
new CommandClient(socket).start();
System.out.println("Connected OK");
}
public static void runServer() throws Exception {
ServerSocket server = new ServerSocket(port); //
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -