Elo guys, i have trying to develop a client/server application! i'm new with sockets, so i'm trying to learn from existing source codes. I have come accros a piece of code:
public static void main(String args[]) {
// validate parameters:
if (args.length != 2) {
System.err.println("Usage: java GameClient <host> <friend_port>");
System.exit(1);
}
// trying to connect to the server:
try {
String serverAddress = args[0];
int serverPort = Integer.parseInt(args[1]);
socket = new Socket(serverAddress, serverPort);
} catch (Exception e) {
System.err.println("Wrong arguments -> " + e);
System.exit(1);
}
System.out.println(socket);
// open in and out streams for talking with the server:
try {
in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
out = new PrintStream(socket.getOutputStream());
}
catch (IOException e) {
System.err.println("Open streams -> " + e);
System.exit(1);
}
// print the address of player - for verification:
InetAddress localHost = null;
try {
localHost = InetAddress.getLocalHost();
} catch (UnknownHostException e) {
System.out.println("Unknown host - probably localhost with no IP!");
// no exit, since can work on "localhost" without internet.
}
System.out.println("Player's local address: " + localHost);
// create GameClient and show its window:
new GameClient();
}
the problem is first few lines where it has to validate the parameters
if (args.length != 2) {
System.err.println("Usage: java GameClient <host> <friend_port>");
System.exit(1);
}
String serverAddress = args[0];
int serverPort = Integer.parseInt(args[1]);
and got this error while running the code
Usage: java FriendClient <host> <friend_port>
where args[0] and args[1] comes from and where does args[0] and args[1] get their values from ?????
can anyone help please....!!!!