aspose file tools*
The moose likes Java in General and the fly likes FileChannel#map for IPC? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "FileChannel#map for IPC?" Watch "FileChannel#map for IPC?" New topic
Author

FileChannel#map for IPC?

James Kirk
Greenhorn

Joined: Dec 12, 2011
Posts: 7
Hi all,
I need to pass masses of data between two processes. Apart from sockets etc, using mmap is a standard approach for native programmes. Java FileChannel supports map, but there it reads:
"Read/write: Changes made to the resulting buffer will eventually be propagated to the file; they may or may not be made visible to other programs that have mapped the same file."
http://docs.oracle.com/javase/7/docs/api/java/nio/channels/FileChannel.html#map(java.nio.channels.FileChannel.MapMode,%20long,%20long)

So the FileChannel#map is not guaranteed to work for IPC? Has someone here successfully used it anyway?

Many TIA,
-- JK
Stephan van Hulst
Bartender

Joined: Sep 20, 2010
Posts: 3647
    
  17

Well, I haven't really used memory mapped I/O so far, so I can't be sure, but maybe some of the methods of MappedByteBuffer can help you out.

If not, and this type of performance is really what you want, maybe it's best to write native code that handles IPC, and then use JNA to invoke these native methods.
James Kirk
Greenhorn

Joined: Dec 12, 2011
Posts: 7
Stephan van Hulst wrote:Well, I haven't really used memory mapped I/O so far, so I can't be sure, but maybe some of the methods of MappedByteBuffer can help you out.

If not, and this type of performance is really what you want, maybe it's best to write native code that handles IPC, and then use JNA to invoke these native methods.


The method I mentioned above creates the MappedByteBuffer. A MappedByteBuffer alone can not be used for IPC, thus the well known workaround to map a shared file.

Cheers,
JK
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: FileChannel#map for IPC?