nio

Deep copy duplicate() of Java's ByteBuffer

java.nio.ByteBuffer#duplicate() returns a new byte buffer that shares the old buffer's content. Changes to the old buffer's content will be visible in the new buffer, and vice versa. What if I want a deep copy of the byte buffer? ...

C# ==> High performance server?

I know that in java when u want to create a high performance server you use nio instead of the regular socket. So is there such a thing for C#, to create high performance servers? ...

Advence Socket Progarmming - Sever to client extra data transfer problem

Dear All, Here One server and one client is there. And communication has been maintained by selectable Channel. like-- Server --- SelectionKey selectKey = channel.register(this.selector, SelectionKey.OP_ACCEPT); while (selectKey.selector().select() > 0) { Set<SelectionKey> selectedKeys = this.selector.selectedKeys(); ...

Deallocating Direct Buffer Native Memory in Java for JOGL

Hello there, I am using direct buffers (java.nio) to store vertex information for JOGL. These buffers are large, and they are replaced several times during the application life. The memory is not deallocated in time and I am running out of memory after a few replacements. It seems that there is not good way to deallocate using java.n...

Using Java NIO for pipelined Http

Researching the web, I've found that pipelined Http is much faster and more power efficient (specially for mobile devices) than queued or parallel connections. The support from general libraries however seams to be small. Just recently has the widespread Apache HttpCore project gained support through its NIO module. At least it says so ...

Can Java non-blocking io be used for the described application?

Hi all, I had built a java TCPServer using serversocketchannels running on one port. However, it is not very scalable as it attends to one incoming socket (blocking mode) only. I want to extend this TCPServer to service multiple incoming sockets (maximum 10 incoming sockets). As such, am wondering if i should implement the TCPServer us...

understanding Java NIO concepts

Can someone suggest a good book/tutorial to understand Java NIO from the operating system perspective (in comparison with java.io?) ...

Non-Blocking File IO in Java..

I want to write to a named pipe (already created) without blocking on the reader. My reader is another application that may go down. If the reader does go down, I want the writer application to neep writing to the named pipe. Something like a fopen(fPath, O_NONBLOCK) in Java. So that when the reader comes up, it may resume from where it ...

Java Rolling File Creation Fails when attempting to read simultaneously

I am using java.util logging classes to create a rolling file appender. I want to create a log reader that reads from these logs as data is written to them. The rolling log appender code works fine on its own. But once I start the reader thread new files are not created i.e. if rolling log appender is set to use 5 files it will create ...

Not able to open selector in solaris for non root user

I have a server application which runs fine in most of the cases but in one solaris machine it not able to open the selector ,for root user it is working fine. for other user it is giving the below exception java.io.IOException: Permission denied at sun.nio.ch.DevPollArrayWrapper.init(Native Method) at sun.nio.ch.DevPollArrayWrapper.<in...

Why the odd performance curve differential between ByteBuffer.allocate() and ByteBuffer.allocateDirect()

I'm working on some SocketChannel-to-SocketChannel code which will do best with a direct byte buffer--long lived and large (tens to hundreds of megabytes per connection.) While hashing out the exact loop structure with FileChannels, I ran some micro-benchmarks on ByteBuffer.allocate() vs. ByteBuffer.allocateDirect() performance. There ...

Considerate migration plan for Java5/Java6 applications to Java 7?

I'm currently investigating if it makes sense to delay some minor planned refactoring work and combine it with the migration to Java 7, but I'm a little bit concerned that it might make it harder to trace the causes of some bugs if both code and platform change at the same time. The benefit of the move would be the ability to clean up a...

Java NIO Framework stops working under heavy load with no write

The problem is fairly odd to me although I'm a newbie. Whats going on is that if you force the server under heavy load of connections and keep sending a invalid packet that doesn't represent POLICY_XML packet. Pretty much what I'm trying to say is that if you connect it goes into socket READ OPERATION. Then you never go into send() wh...

Can SelectionKey.isWritable be true without OP_WRITE in interestOps()?

Given a SelectableChannel c and its SelectionKey k, k.isWritable() returns, whether the channel is ready to accept calls to write(). However, can k.isWritable() return true if the channel accepts writes, but OP_WRITE isn't set in interestOps? ...

Using JAVA NIO framework in SPRING server

I'm implementing an hybrid server application that mixes a Web-Servlet and a plain Java application. The java application manages thousands of sockets for remote devices, while the Web application interacts with the user to set/read the state of any socket. Java NIO, or Apache-MINA vs Jboss-Netty, seems to be good options for the socket...

Java NIO for merging sorted files?

I have a bunch of text files on disk, each one is just a sorted list of nonnegative integers, newline delimited: 2 14 67 134 654 1130 My files are pretty big - they can easily contain hundreds of millions of numbers. I want to write a Java program to read each of these files and write out a new text file containing all of the numbers ...

Seeking a ByteArrayInputStream using java.io

How can I seek (change the position) of a ByteArrayInputStream (java.io)? It is something so obvious, but I can't seem to find a method for this anywhere (mark/reset is not enough, I need to set the position to anywhere on the InputStream). If it can't be done using java.io and I must switch to java.nio and use a ByteBuffer, how can I g...

Need async http client(NIO) which supports http/socks proxy

Hi! I seek some full featured async http client (using NIO, not thread per connection), that supports connections through all kinds of proxy(http/https/socks4/socks5). I need different proxy per connection, not one global proxy for all connections. so... what library i can use? P.S. sorry for my english ...

Java: Get Notified On Incoming Packet

Hello, I'm working on a library that is currently using standard tcp sockets. An end user of my library registers themselves as a listener, and needs to be notified if/when a relevant message comes in. If I spawn a worker thread within my library, there is a thread-death problem where my library may prevent the application from termin...

One thread per client. Doable?

I'm writing a Java server which uses plain sockets to accept connections from clients. I'm using the fairly simple model where each connection has its own thread reading from it in blocking mode. Pseudo code: handshake(); while(!closed) { length = readHeader(); // this usually blocks a few seconds readMessage(length); } cleanup();...