CLient IP + Port is now read and shown
parent
5e81f4f979
commit
5099a7b4d6
|
|
@ -37,9 +37,15 @@ public class SyslogServer {
|
||||||
packet.getData(), // complete byte array be aware: packet.getData() returns the entire buffer, not just the received data
|
packet.getData(), // complete byte array be aware: packet.getData() returns the entire buffer, not just the received data
|
||||||
packet.getOffset(), // get the offset where the data starts
|
packet.getOffset(), // get the offset where the data starts
|
||||||
length,
|
length,
|
||||||
StandardCharsets.UTF_8);
|
StandardCharsets.UTF_8); // Convert the byte array to a string using UTF-8 encoding
|
||||||
|
|
||||||
System.out.println("Nachricht empfangen!" + message);
|
System.out.println("Nachricht received: " + message);
|
||||||
|
|
||||||
|
// Show Client IP and Port
|
||||||
|
InetAddress clientAddress = packet.getAddress();
|
||||||
|
int clientPort = packet.getPort();
|
||||||
|
System.out.println("From: " + clientAddress.getHostAddress() + ":" + clientPort);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue