• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Thread Hung on SocketChannel read() method

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've java process which reads data from a socket. Below is the code for reading the data from the socket. The program creates a ServerSocketChannel
and binds it to a socket and accepts the connection from the socket.
Then it creates a bytebuffer with a specified capacity and reads data from the SocketChannel by filling this buffer. This particular logic runs in an
infinite loop, as there is continuous flow of data.

I'm pasting the code below:

The process runs for sometime, reads the data and hangs after sometime at the SocketChannel read() method. I took the thread dump of the process which is below:

at sun.nio.ch.FileDispatcher.read0(Native Method)
at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:38)
at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:258)
at sun.nio.ch.IOUtil.read(IOUtil.java:225)
at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:223)

If i restart the process, it starts processing the data again and after sometime goes in to a hung state.

One more thing I noticed is that there are lot of CLOSE_WAIT connections on the socket in which the process is reading data.

Can any one help in identifying what is going wrong here?

[ October 03, 2008: Message edited by: Ganesh Dhakshinamurthy ]
Please use code tags
[ October 03, 2008: Message edited by: Joe Ess ]
 
It is an experimental device that will make my mind that most powerful force on earth! More powerful than this tiny ad!
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic