I am sending a message via a DatagramChannel as follows:
ByteBuffer buf = ByteBuffer.allocate(48);
buf.clear();
String request_message = "request";
buf.put(request_message.getBytes());
buf.flip();
int bytesSent = udpserver.send(buf, successor_port_1); // udpserver is a DatagramChannel
I then read the message on the server:
ByteBuffer buf = ByteBuffer.allocate(48);
buf.clear();
String message = new String(buf.array(), Charset.forName("UTF-8"));
System.out.println(message); //print message for testing purposes
if (message == "request"){
//code here does not get executed
}
The problem is, my code doesn't enter the "if" statement even though message = "request" which also seems to be confirmed by my print statement.
Any help would be appreciated!