
I am doing socket programming. I have two files called Server.java and client.java. Both programs were running successfully and successfully sending data to each other. Yesterday I added the following lines to client.java file:
//old line
out.writeUTF(dbdata); //dbdata was written successfully and sent to the server program
try
{
//my socket connection object name is sock
String data1="1000";
System.out.println(data1);
out.writeUTF(data1); this line causes the error
}
catch(Exception e)
{
System.out.println("Exception :: "+e);
}
When the line out.writeUTF(data1) is executed and catch catches it and shows the exception as BROKEN PIPE.
The contents of server.java which reads data1 is given below:
String data1;
try
{
data1=in.readUTF();
}
catch(Exception e)
{
System.out.println("Server Exception :: "+e);
}
I also checked if connection is open with isConnected() before out.writeUTF(data1) and after the exception occurs in the catch I executed isConnected(). Both the times it showed True only.
The exception that pops up is ----- java.net.SocketException: Broken pipe
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.