Skip to content

Commit

Permalink
fix compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
rohitpaulk committed Nov 27, 2023
1 parent 6302fd9 commit 575329e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
5 changes: 2 additions & 3 deletions solutions/java/01-init/code/src/main/java/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@

public class Main {
public static void main(String[] args){
int port = 2053;
while(true) {
try(DatagramSocket serverSocket = new DatagramSocket(port)) {
try(DatagramSocket serverSocket = new DatagramSocket(2053)) {
final byte[] buf = new byte[512];
final DatagramPacket packet = new DatagramPacket(buf, buf.length);
serverSocket.receive(packet);
System.out.println("Received " + new String(buf) + " from " + serverSocket.getInetAddress());
System.out.println("Received data");

final byte[] bufResponse = new byte[512];
final DatagramPacket packetResponse = new DatagramPacket(bufResponse, bufResponse.length, packet.getSocketAddress());
Expand Down
7 changes: 3 additions & 4 deletions solutions/java/01-init/diff/src/main/java/Main.java.diff
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@@ -1,27 +1,23 @@
@@ -1,27 +1,22 @@
import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
Expand All @@ -7,13 +7,12 @@
public static void main(String[] args){
- // You can use print statements as follows for debugging, they'll be visible when running tests.
- System.out.println("Logs from your program will appear here!");
+ int port = 2053;
+ while(true) {
+ try(DatagramSocket serverSocket = new DatagramSocket(port)) {
+ try(DatagramSocket serverSocket = new DatagramSocket(2053)) {
+ final byte[] buf = new byte[512];
+ final DatagramPacket packet = new DatagramPacket(buf, buf.length);
+ serverSocket.receive(packet);
+ System.out.println("Received " + new String(buf) + " from " + serverSocket.getInetAddress());
+ System.out.println("Received data");

- // Uncomment this block to pass the first stage
- //
Expand Down

0 comments on commit 575329e

Please sign in to comment.