I created a class TFTPClient
which allows user to connect to the server and able to make certain request through the class methods. I have created and tested this outside of Android Studio, but when I transferred and compiled my code I get an error. The error is caused in the MainActivity.java but not when creating the class object, but calling certain method
TFTPClient c = new TFTPClient(); //Works fine
try {
c.sendAndReceive(); //Get the error
} catch (UnknownHostException e) {
e.printStackTrace();
}
Here is the sendAndReceive method code
public void sendAndReceive() throws UnknownHostException {
int sendPort;
sendPort = SERVER_RECV_PORT; //(60700)
int clientConnectionPort = -1;
InetAddress serverAddress = InetAddress.getByName("172.17.49.153");
try {
clientConnectionPort = sendRequest(serverAddress, sendPort, "all");
}
catch (IOException e) {
//System.out.println("error");
}
receive(serverAddress, clientConnectionPort);
}