This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Sockets and Internet Protocols and the fly likes Another Java NIO stumble Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "Another Java NIO stumble" Watch "Another Java NIO stumble" New topic
Author

Another Java NIO stumble

Evgeni Dimitrov
Greenhorn

Joined: Dec 20, 2012
Posts: 2
I have a small server, which works under Windows and fails under Red Hat. The idea is:

- a main thread with a ServerSocketChannel and a Selector
- when it accepts a connection, it creates an Event with the SocketChannel in it
- the Event is offered to the Queue
- each Worker thread has its own Selector and a DB Connection
- the Worker thread takes the Event from the Queue, sets the Selector and the DB Connection in it and calls Event's method getProcessed
- the Event reads the SocketChannel (always fine), queries the DB (always fine) and writes to the SocketChannel (works under Windows and fails under Red Hat)

the code is:


I will appreciate any comments and suggestions.

When it fails under Red Hat the browser shows "The connection was reset". Although only twice (out of 50 attempts) I got the correct response under Red Hat - judging by the log - the Opera browser has tried 4 times in a row and eventually has got the response.

When it succeeds and when it fails, the log is always perfect:
1. limit::137
1. position::0
1. remaining::137
2. limit::137
2. position::137
2. remaining::0
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Another Java NIO stumble
 
Similar Threads
NIO Socket weirdnes in Solaris 2.10
Blocking queue Implementation
socket programming : connect server to client
ServerSocketChannel.accept() seems to create a random port to send data to?
Another NIO stumble