So... for some reason, this code is failing to enter the 'if' statement at processInput()... and I have no idea why. Any kind of explanation?
Thanks in advance.
public static void processInput(String input) throws Exception{
System.out.println("I got into process!");
String[] splitInput = input.split(" ");
System.out.println(splitInput[0]); // returns TQR
if(splitInput[0].equals("TQR")){ // .equals("TQR\n" won't do anything either
System.out.println("Why aren't you here :( ???");
System.out.println("List request: " + IPAddress.getHostName() + " " + clientPort);
sendData = "Just send something".getBytes();
sendPacket = new DatagramPacket(sendData, sendData.length, IPAddress, port);
serverSocket.send(sendPacket);
}
}
public static void main(String args[]) throws Exception {
port = Integer.parseInt(args[1]);
serverSocket = new DatagramSocket(port);
receiveData = new byte[1024];
sendData = new byte[1024];
while(true){
receivePacket = new DatagramPacket(receiveData, receiveData.length);
serverSocket.receive(receivePacket);
String input = new String(receivePacket.getData());
InetAddress IPAddress = receivePacket.getAddress();
int port = receivePacket.getPort();
processInput(input);
}
}
Aucun commentaire:
Enregistrer un commentaire