From 7aed603c5689c07f031231104597ae1b04d0c63a Mon Sep 17 00:00:00 2001 From: Sebastian Rieger Date: Wed, 7 Nov 2018 17:40:03 +0100 Subject: [PATCH] changed serverSocket var name to datagramSocket to avoid confusion --- .../socket/reuse/UDPServerReuse.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/VerteilteSysteme-Examples/src/verteiltesysteme/socket/reuse/UDPServerReuse.java b/VerteilteSysteme-Examples/src/verteiltesysteme/socket/reuse/UDPServerReuse.java index 52d15b7..665e982 100644 --- a/VerteilteSysteme-Examples/src/verteiltesysteme/socket/reuse/UDPServerReuse.java +++ b/VerteilteSysteme-Examples/src/verteiltesysteme/socket/reuse/UDPServerReuse.java @@ -8,18 +8,18 @@ class UDPServerReuse { public static void main(String args[]) throws Exception { int udpPort = 36037; @SuppressWarnings("resource") - DatagramSocket serverSocket = new DatagramSocket(null); + DatagramSocket datagramSocket = new DatagramSocket(null); // erlaubt das Wiederverwenden des Ports, mehrere Server-Prozesse können gleichen Port nutzen - serverSocket.setReuseAddress(true); - serverSocket.bind(new InetSocketAddress(udpPort)); + datagramSocket.setReuseAddress(true); + datagramSocket.bind(new InetSocketAddress(udpPort)); byte[] receiveData = new byte[1024]; byte[] sendData = new byte[1024]; - System.out.println("UDP Server started. Waiting for incoming requests... (reuseAddress="+serverSocket.getReuseAddress()+", timeout="+serverSocket.getSoTimeout() +", buffersize="+serverSocket.getReceiveBufferSize()+")"); + System.out.println("UDP Server started. Waiting for incoming requests... (reuseAddress="+datagramSocket.getReuseAddress()+", timeout="+datagramSocket.getSoTimeout() +", buffersize="+datagramSocket.getReceiveBufferSize()+")"); while (true) { DatagramPacket receivePacket = new DatagramPacket(receiveData, receiveData.length); - serverSocket.receive(receivePacket); + datagramSocket.receive(receivePacket); String sentence = new String(receivePacket.getData(), 0, receivePacket.getLength()); InetAddress IPAddress = receivePacket.getAddress(); @@ -30,7 +30,7 @@ class UDPServerReuse { String capitalizedSentence = sentence.toUpperCase(); sendData = capitalizedSentence.getBytes(); DatagramPacket sendPacket = new DatagramPacket(sendData, sendData.length, IPAddress, clientSrcPort); - serverSocket.send(sendPacket); + datagramSocket.send(sendPacket); } } }