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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Is it possible to read data after nio socket channel closed?

 
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
I am also posting my question in this forum in hope of getting more responses.

I have an NIO Socket Server "S1".
I have an NIO Socket Client thread T1 having reference to a valid socket channel connected to "S1"

S1 sends messages to T1 say of 100 bytes each in an infinite loop.

T1 runs in an infinite loop & has a read() method which reads from the socket channel when the Selector registered with it receives an OP_READ key. After each successful read thread T1 sleeps for 5 seconds.

Here are some questions looking to be answered:

1.) What happens to the messages sent by S1 when thread T1 is sleeping ?

2.) Does the Selector registered with the Socket Channel buffer the messages irrespective of the fact that T1 is sleeping ?

3.) If answer to 2.) is YES then what happens when Server S1 has sent say 500 bytes while T1 was sleeping and then S1 disconnects due to some IOException before T1 wakes up. Have those 500 bytes sent by S1 before disconnecting been received and buffered by the Selector?
If they have been received and buffered then is it possible to retrieve them?

Any help is appreciated.
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator

Harvinder Thakur wrote:I am also posting my question in this forum in hope of getting more responses.
.



Please do not post the same question more than once. Your original question is in the correct forum. If no one answers your question, it may be because NIO is the "road less traveled" and not many people have in-depth experience with it.
 
Don't get me started about those stupid light bulbs.
    Bookmark Topic Watch Topic
  • New Topic