main
parent
9bbc0acae5
commit
96464ec730
|
|
@ -4,6 +4,7 @@ import java.io.IOException;
|
||||||
import java.net.DatagramPacket;
|
import java.net.DatagramPacket;
|
||||||
import java.net.DatagramSocket;
|
import java.net.DatagramSocket;
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
|
import java.net.SocketAddress;
|
||||||
|
|
||||||
public class Client {
|
public class Client {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|
@ -22,7 +23,18 @@ public class Client {
|
||||||
DatagramPacket packetIn = new DatagramPacket(new byte[512], 512);
|
DatagramPacket packetIn = new DatagramPacket(new byte[512], 512);
|
||||||
socket.receive(packetIn);
|
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) {
|
catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue