Here's my Java server program, wich expects a cliente to be connected with it. The question is, using command line can I connect to this server program using telnet? If I do, what's the command I must use to do so?
import java.io.*;
import java.net.*;
public class Server {
public static void main(String args[]) {
try {
ServerSocket serverSocket = new ServerSocket(4433);
Socket socket = null;
while(true) {
System.out.print("Waiting connection...");
socket = serverSocket.accept();
System.out.println("Connected!");
BufferedReader input = new BufferedReader(new InputStreamReader(socket.getInputStream()));
PrintStream output = new PrintStream(socket.getOutputStream());
String line = input.readLine();
while(line != null && ! line.trim().equals("")) {
output.println("You have sent me: " + line);
line = input.readLine();
}
socket.close();
}
}
catch(IOException ioe) {
System.out.println(ioe);
}
}
}