I'm having a few problems using sockets and connecting to a server.
I've got a server.jar file that runs on my machine and I have a client interface that needs to connect to the server and send and recieve messages using output/input streams.
Firstly, the socket constructor is Socket(remoteHost, port). I've got the port number, but as the server is running on my own machine should I use my hostname/ip address as the remoteHost as this is what I'm currently doing? This method does connect to the server (which is confirmed in the terminal window running the server), which in turn creates a GUI.
Once connected, I'm able to send messages to the server using a BufferedWriter. There is a logout command which is called by a button on the GUI. To logout, a message is sent to the server and log's the user off correctly. However, I also need to close the socket. This is the code I'm using >
When this code is inserted and the logout button is clicked the system freezes and doesn't logout, despite this code appearing after the logout command has been sent to the server. Is there any obvious reason why this would happen?