• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Serializing a file over RMI

 
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a functioning RMI application, and I have decided that I want the client to be able to send a 1GB file to the server. Obviously, as this is RMI, I can't just pass in a FileInputStream to my remote method call. Also, I can't read the whole file in to a bytearray and send that over, since the file is too big to fit in memory.

What's the best way (or any way) to do this, then? I assume that there's some standard way to do this, but I haven't been able to figure it out.

Thanks for any suggestions and advice
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As you've found - RMI isn't a great way to send files full of data - so why do you want to only use RMI to do this? One good approach is to have the server respond to the client with *where* it can get the file (as a URL), and then have the client use FTP or some other protocol to download the file.
 
Tom McAmmond
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The client is sending the file to the server, not vice-versa....

My client app runs on a user's desktop and performs all operations against the server via RMI. The client has no HTTP or FTP server running, and user requirements specify that this will not change. Can I open a socket or something? There's got to be a way to do this - I can't be the only person who's wanted to send a file from a client to a server.....
[ August 15, 2005: Message edited by: Tom McAmmond ]
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oops... sorry, didn't notice that the file was coming from the client until you pointed it out...

Hmmm... not sure if there's a "standard" or "common" way of going about this...

You wouldn't necessarily need a FTP server running on the client to use FTP - you could have an FTP server running on the server and use the FTP protocol to send the files from the client.

This would probably require you to dig a bit into FTP protocol internals.

You could also definitely use straight sockets to do this, too - something like -

1.) Have the client call a server RMI method that returns an IP and port to send the file to.
2.) The server start up a ServerSocket and return it's IP and port to the client.
3.) The client then opens a socket using the data supplied, opens an output stream to the file (hopefully wrapped in a buffered stream, and maybe even using a gzipped stream to speed things up) and stream the file data across the socket.

Hopefully this helps you figure a good approach out...
 
Ranch Hand
Posts: 473
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am writing this so that anyone need help in this regard is guided,

There is RMIIO that is helpful in this regard.

http://openhms.sourceforge.net/rmiio/

Thanks,

Maki Jav
 
reply
    Bookmark Topic Watch Topic
  • New Topic