I have this line of code in server.java file that create a sever and take the arge[0] as port but it show ArrayIndexOutOfBoundsException
//create a Server object
Server server = new Server();
//show GUI:
server.pack();
server.setVisible(true);
server.setSize(new Dimension(400, 200));
//get RTSP socket port from the command line
int RTSPport = Integer.parseInt(argv[0]);
server.RTSP_dest_port = RTSPport;
//Initiate TCP connection with the client for the RTSP session
ServerSocket listenSocket = new ServerSocket(RTSPport);
server.RTSPsocket = listenSocket.accept();
listenSocket.close();
The same thing goes for client.java file
//Create a Client object
Client theClient = new Client();
//get server RTSP port and IP address from the command line
//------------------
int RTSP_server_port = Integer.parseInt(argv[1]);
String ServerHost = argv[0];
theClient.ServerIPAddr = InetAddress.getByName(ServerHost);
//get video filename to request:
VideoFileName = argv[2];
//Establish a TCP connection with the server to exchange RTSP messages
//------------------
theClient.RTSPsocket = new Socket(theClient.ServerIPAddr, RTSP_server_port);
I also try using Scanner and BufferedReader to get port from terminal but the client doesn't seem to connect to the server. Is there any other way?