Java client hangs if I open two clients at once

I’m trying to build a chat-like thing, and the idea is that whenever someone types, it gets sent and printed on every client connected. If I only open the server and one client, everything runs …

Send a 2D Matrix from Client to Server in Java using TCP connection (Socket Programming)

I need to send a 2D matrix from the client to the server-side using the following packages: import java.io.DataInputStream; import java.io.DataOutputStream; import java.net.Socket; I have read a …

What is the best way to update the ip adress of serversocket for clients?

I’m programming a little server example with Sockets in Java. Currently I’m using this for testing: server= new Socket(InetAdress.getByName(“127.0.0.1”),3333) but my plan is to move it to …

Proper way to close an AutoCloseable

What is the most reliable pattern to follow when closing an OutputStream, ServerSocket, or other object that implements the AutoCloseable interface? Should I use try-catch-finally? Or a shutdown hook….