Hi all, I am writing a chatting application. This is the first time I am using sockets. In the first level I tried to connect to a server socket, ping it and close the connection. The server will not respond. This went fine. Then in the second step I thought why not server respond to me. So introduced input and output streams in both client and server. I am getting some errors while trying to close the server's output stream in the client program. And errors in the server socket program too.
As of now the server is only able to respond to single client. In the next level I will try to make my server handle many clients and the last version will be like server is central and clients will be chatting with each other.
I am putting my code. Can anyone please tell me what mistake I am doing. The code is lengthy. I wrote multiple files of same code to debug it better in eclipse IDE.
Client.javaServer.javaThe exceptions I am getting are
1. When "end" is input it is not written to the socket, your if statement breaks out of your while loops before doing so.
2. Even if the "end" string is sent to the server the client is still left expecting a return string through the input stream of the socket.
3. You havent closed the socket.
Similar problems in the server code.
There is no need for seperate threads to read and write to the socket, you should start again and use a single thread for that purpose. You can use most of the code you have and just close your streams and sockets when your finished with them.