This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
    Bookmark Topic Watch Topic
  • New Topic

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

 
Harvinder Thakur
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
  • 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.
 
Joe Ess
Bartender
Pie
Posts: 9264
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • 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.
 
    Bookmark Topic Watch Topic
  • New Topic