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); } } }