I'm writing a Stomp protocol client with Java and it has only one thread to process IO. That means that thread reads and writes incoming data to the application back and forth. My issue is if I need to scale this application in future with multi threading and NIO, how that could be arranged?
my IO processor thread is called "TcpLink" li...
Hello All,
Im working on a socket listener that has to listen on 2 ports for 2 types of data( port 80 and port 81). These data are very similar as in the kind of operations that are performed on the data and are just different because they arrive n different ports. I went ahead and coded an implementation using Java's ServerSocket class...
I'm trying to use NIO to assemble a file out of several smaller files, using transferFrom.
The call to transferFrom returns 0. No exception. Nothing done to turn on synchronous behavior.
FileOutputStream fos = new FileOutputStream(path);
FileChannel fileBeingAssembled = fos.channel();
int progressiveOffset = 4096;
FileI...
I am converting some Java NIO code to run in Scala and I am getting an error because the SelectionKey I'm calling returns a SelectableChannel rather than a DatagramChannel, which is a subclass of SelectableChannel and an instance of which I declare at the beginning of the code. I did not come to Scala from Java, so my knowledge of Java i...
I have a text editor that uses code almost identical to the below for reading and writing. When I open small files for editting, I always get this error when I try to save them again. The really interesting thing though is that my text editor works fine for files with about 600 bytes or more (seems to vary each time), behaviour that I ha...
In some circumstances I wish to send an error message from a server to client using non-blocking I/O (SocketChannel.write(ByteBuffer)) and then disconnect the client. Assuming I write the full contents of the message and then immediately disconnect I presume the client may not receive this message as I'm guessing that the OS hasn't actu...
I need a little help with the JProgressBar component. My program copies files from one place to another using java.nio FileChannels. The actual copy method is transferFrom().
I've got two questions now.
How to I monitor the transfer progress of FileChannels? All tutorials I've found use the conventional java.io InputStreams and increa...
When working with NIO sockets in Java, once I'm connected I can either register for both read and write operations and just do nothing whenever I get a write notification and I have nothing in the outbound buffer, or I can register for read notifications only and re-register for read and write only when something is placed in the outboun...
Hi,
How can I do long-polling using netty framework? Say for example I fetch http://localhost/waitforx
but waitforx is asynchronous because it has to wait for an event? Say for example it fetches something from a blocking queue(can only fetch when data in queue). When getting item from queue I would like to sent data back to client. Ho...
I've got a moderately big set of data, about 800 MB or so, that is basically some big precomputed table that I need to speed some computation by several orders of magnitude (creating that file took several mutlicores computers days to produce using an optimized and multi-threaded algo... I do really need that file).
Now that it has been...
Exception in thread "Thread-0" java.lang.NullPointerException
at org.apache.http.impl.nio.reactor.AbstractIOReactor.closeActiveChannels(AbstractIOReactor.java:532)
at org.apache.http.impl.nio.reactor.AbstractIOReactor.hardShutdown(AbstractIOReactor.java:564)
at org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor.doShutdo...
Java nio establishes lots of connections, How to do a count?
...
I have a problem (and need to past in the source code.)
I/O error: I/O dispatch worker terminated abnormally
Exception in thread "Thread-1"
java.lang.IllegalStateException: I/O reactor has been shut down at
org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor.connect(
DefaultConnectingIOReactor.java:190)
...
From what I read about Java NIO and non-blocking [Server]SocketChannels, it should be possible to write a TCP server that sustains several connections using only one thread - I'd make a Selector that waits for all relevant channels in the server's loop.
Is that right, or am I missing some important detail? What problems can I encounter?...
Hi
The specification of ReadableByteChannel.read() shows -1 as result value for end-of-stream. Moreover it specifies ClosedByInterruptExceptionas possible result if the thread is interrupted.
Now I thought that would be all - and it is most of the time. However, now and then I get the following:
java.io.IOException: Eine vorhandene Ve...
Hi
Usually you have a single bound tcp port and several connections on these. At least there are usually more connections as bound ports. My case is different: I want to bind a lot of ports and usually have no (or at least very few) connections.
So I want to use NIO to accept the incoming connections.
However, I need to pass the accep...
Using non-blocking I/O, the code for connecting to a remote address looks something like:
SocketChannel channel = SelectorProvider.provider().openSocketChannel();
channel.configureBlocking(false);
channel.connect(address);
The connection process will then have to be finished by invoking finishConnect() on the channel when some selecto...
The release notes for Java NIO (in Java 1.4+) state that support for direct ByteBuffers is an optional feature. I am curious which JVM vendors/flavors do not support it? Should a JNI library always code for managed ByteBuffers and relegate direct ByteBuffers as an optimization?
Thanks
...
I am writing a networking application using the java.nio api. My plan is to perform I/O on one thread, and handle events on another. To do this though, I need to synchronize reading/writing so that a race condition is never met.
Bearing in mind that I need to handle thousands of connections concurrently, is synchronization worth it, or ...
I'm converting a Java server application which used blocking IO and thread-per-client to NIO and a single IO thread (probably a thread pool after I get the basic implementation done). The one thing I am having an issue with is disconnecting clients after they have been idle for a period.
I had previously been using SO_TIMEOUT and block...