File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Sockets and Internet Protocols and the fly likes Read operation failed from Socket. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Make it so: Java DB Connections & Transactions this week in the JDBC forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "Read operation failed from Socket." Watch "Read operation failed from Socket." New topic

Read operation failed from Socket.

MuraliManohar Chepuri

Joined: Sep 29, 2010
Posts: 5

We had a legacy application built on IBM RAD tech stack which has Socket Server and client ( Client is a third party application)
Server was using BufferedReader and BufferedWriter to read and write data from sockets in IBM-1025 Char set.

Now i am re writing the same server in Java6

As part of application specific protocol....

After the successful connection client should send a time stamp in str format to start the communication.

Here ... the new server is failing to read the data and is on hold for some time @ read statement before Connection times out.
Here i used diff alternates to get this worked.
But could not able to succeed.


So thought of asking help to figure out ..

Wouter Oet
Saloon Keeper

Joined: Oct 25, 2008
Posts: 2700

I'm assuming that you're using the method BufferedReader.readLine(). That method reads a line from the buffer. A line is terminated either by a line feed, carriage return or both. So if the client doesn't send a line terminator then the method will block and wait until one is send.

"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
MuraliManohar Chepuri

Joined: Sep 29, 2010
Posts: 5
I am not using readLine method...

I am using read method

private String receiveMessage(int pBytesToRead)
throws SocketTimeoutException, IOException
String methodName = "String receiveMessage(int pBytesToRead)";
char charArray[] = new char[pBytesToRead];, START_POS, pBytesToRead);

_logger.logp(Level.FINEST, CLAZZ_NAME, methodName,
"Read : " + new String(charArray));
return new String(charArray);
I agree. Here's the link:
subject: Read operation failed from Socket.
It's not a secret anymore!