CLient IP + Port is now read and shown

Corinna
smittythekid 2026-04-08 18:49:56 +02:00
parent 5e81f4f979
commit 5099a7b4d6
1 changed files with 8 additions and 2 deletions

View File

@ -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.getOffset(), // get the offset where the data starts
length,
StandardCharsets.UTF_8);
StandardCharsets.UTF_8); // Convert the byte array to a string using UTF-8 encoding
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);
System.out.println("Nachricht empfangen!" + message);
}
}