Victor Hans-Georg Waitz 2025-10-21 18:41:06 +02:00
parent 9bbc0acae5
commit 96464ec730
1 changed files with 13 additions and 1 deletions

View File

@ -4,6 +4,7 @@ import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.net.SocketAddress;
public class Client {
public static void main(String[] args) {
@ -22,7 +23,18 @@ public class Client {
DatagramPacket packetIn = new DatagramPacket(new byte[512], 512);
socket.receive(packetIn);
System.out.println("Received from IP: " + packetIn.getSocketAddress());
System.out.println("Recieved!");
int senderPort = packet.getPort();
String senderHost = senderAddress.getHostAddress();
SocketAddress senderSocketAddress = packet.getSocketAddress();
System.out.println("Sender IP: " + senderHost);
System.out.println("Sender Port: "+ senderPort);
System.out.println("Sender socket address: " + senderSocketAddress);
System.out.println("Received from IP: " + senderHost);
// System.out.println("Received from IP: " + packetIn.getSocketAddress());
}
catch (IOException e) {
e.printStackTrace();