Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Programming Talk / Java / JSP - Slow transfer speeds...

Author
Message
Mr Z
18
Years of Service
User Offline
Joined: 27th Oct 2007
Location:
Posted: 17th Oct 2009 18:11 Edited at: 17th Oct 2009 18:29
Hi all.

I have some very strange issues in my file transfer application. Every part of it seems to work well EXCEPT for the file transfer part, which acts very unstable. For example, I cannot have too small buffers when transfering to another computer, because then the connection dies, I must have a 1 milisecond delay on the server side after I send the buffer (that contains a peace of the file I want to transfer), or the connection dies, I cannot do this, I cannot do that, sometimes the connection just dies and sometimes it works.

When I look at the exceptions they tend to say "Broken pipe" or "Connection reset".

It is really frustrating. And now I may have found a solution (have only tested it locally so far, and it seems to take away an issue I have when I do that), BUT of course it makes the transfer many times slower. This is driving me nuts.

Note that this is my first real attempt to make a file transfer, so I do not know very much about how to do it in a good way. Could anyone take a look at the code for me and help me to develop a better way to transfer the files? One that does not give all these errors?

(Should warn you, there is a lot of code here... probably does not need to be this large, I might add, this is as stated my first real try at something like this.)

The code on the sending side:


The "getBuffer" method will simply make sure I do not read in the entire file into memory, but a peace at a time, making it theoretically possible to send huge files (basically it just checks how much data is available in the stream, and if it is larger then the set buffer size it will simply return an array with the size of the buffer). If you want to take a closer look, here is the code for it:


And here is the receiving sides code:


Can anyone help me? I am not sure where the error is, if it has to do with the communication between the server and client or if it occurs when I try to read data from a file. Could be anything, have no real idea myself... and sometimes it appear to work for no reason. Other times it refuses to. Anyone have an idea?

Take care,
Mr Z

EDIT:

Also, I run this transfer in an own thread on both the sending and the receiving side. Do not know if that matters.

"Operator! Give me the number for 911!"
- Homer J. Simpson

Login to post a reply

Server time is: 2026-06-10 09:32:11
Your offset time is: 2026-06-10 09:32:11