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 smoothly — whenever I send something from the client, it goes to the server and then it comes back and gets printed on the client.
Tag: serversocket
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: I have read a matrix from the user and I need to send to the server to perform certain operations on it. How do I send the complete matrix across? I am sending multiple variables and not just a matrix. I am sending
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: but my plan is to move it to my Raspberry Pi. Unfortunately, I don’t have a static IP address. What is the proper way to update the IP address in the code? I thought about storing it on a webserver and accessing it via
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. Answer The correct way to use an AutoCloseable instance is with a try-with-resources block, so the resource is reliably closed even if an exception is thrown. Like this: You can also