• Post Reply Bookmark Topic Watch Topic
  • New Topic

Single Socket Connection Using RMI Socket Factory  RSS feed

 
Ankur Jaiswal
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys,
I am trying to code a piece that must use sockets to connect to a server which is listenning at a port for an incoming file. I want to figure out a way so that i can use streams but, the buffer size should vary with the incoming file size.
I wanted to avoid use of any streams at all and find a way to send an entire file to the remote server.

Note1: The use of RMI Custom Sockets do give us a way to create a single socket and connect to a remote server, making it possible to just have a single program running on one side to send a file.
Note2: The file size is expected to be arouond 1Mb on an average.
Regards,
Ankur
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm a little confused by your message; is the server an RMI server?
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your private message, but let's keep the discussion here on the BB so other people might benefit. As your server is not an RMI server, RMISocketFactory has no place here. That class is used to customize how RMI itself works.
Anyway, now I'm trying to understand your requirements. You want to transfer the file "all at once rather than in a stream." I guess I don't really understand what you want to accomplish. The network cable connecting the computers will move data one single bit at a time; the bits will be assembled at the receiving host into bytes, and those bytes will become the file. Think about it: the network hardware can only transfer one single binary bit at a time.
Now, on top of this one-bit-at-a-time functionality, you've got multiple layers of structure: bits assembled into Ethernet frames, for example, and Ethernet frame payloads assembled into IP packets, and IP packets assembled into TCP packets; the client will send raw data which will be broken into TCP packets, which will be packaged as IP packets, which will be broken into Ethernet frames, with possible fragmentation at every step, and the reverse happens at the other end. It simply makes no sense to talk about "sending the file all at once."
So, what are your actual requirements? Is there a particular problem you're trying to circumvent?
 
Ankur Jaiswal
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
The file that needs to be transferred is of specific format. The format should not be changed at the receving end. Assume the file is 20 MB and im sending it in small chunks of 1K streams. Do we have to do any programming at the server end to accept each of the small 1Ks, got one after the other and then assemble to get the file of 20 MB??
If yes, we cannot do any code at the server end as it a remote sever not accessible by us. The requirement told was that remote server expects a file for processing. so is there any way we can send this large file without doing some server side programming.
Regards,
Ankur
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmmm. I think you probably are coming from a mainframe background, where files may have "record" structure, as kept by the OS. Java's model of a file is like the UNIX model, or the Windows model: a file is just a series of bytes, from beginning to end. If you copy each byte from the source file, and write them in order into the destination file, then you end up with an identical copy. Thus, in pseudo code, the client looks something like

and the server looks like

There are lots of details and enhancements; for example, the client might send the filename and the file size first, and the server might use.

we cannot do any code at the server end as it a remote sever not accessible by us

Now I'm confused again. So are you saying the server program already exists? Then your client just has to send it whatever it's expecting to receive -- you do have some kind of documentation for it, yes?
 
Ankur Jaiswal
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,
I will get back to you as soon as i find the way the remote server is expecting the file to be. And sure now i am clear of how things are supposed to work.
Like i was writing a client and a server where i was passing a file(AS STREAMS OFCOURSE) from the client side and reading it from the server side. But the only problem seems to be that we here still do not know, what way(how many bytes at a time etc ) does the server program reads.
Anyways, thanks a lot for helping me out, will get back to you in a day after consulting.
Thanks
Ankur
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!