efficient network transfer

From: uzon (asb23_at_hotmail.com)
Date: 11/17/04


Date: 17 Nov 2004 13:14:19 -0800

hi,
i'm writing a proxy for file transfers.
for example, one client sends a file to the proxy which forwards it to
another client.
i'm writing code for both the clients (send / receive file) and the
proxy (forward the file).
currently, i have this function to send the file-

InputStream fis = new FileInputStream(f.getPath() + f.separator +
param.filename);
BufferedOutputStream bos = new BufferedOutputStream(os);
do {
                    i = fis.read();
                    if (i != -1) {
                        bos.write(i);
                    }
                } while (i != -1);

the forwarding code is very similar. just the input stream is a socket
not a file.
the receiving code is also similar. the output stream is to a file not
a socket.
this is working ok but it's very slow. it takes several minutes for a
file that's only a few mb.
there are two problems here i don't know how to code better-
1. loading and writing the file byte by byte is REALLY slow. how would
i go about doing it with some kind of buffer saving every X amount
received and what is the recommended amount? i want to support large
file transfers also, so saving the whole file in memory and writing to
disk in the end is not good.
2. sending byte by byte on the network (especially for the forwarder-
proxy, is also very slow). so here i also need some kind of buffer to
accept X amount and then send it.
i know there are other sending/receiving functions in java but don't
know which to use, or exactly how to use them.

any help would be greatly appreciated.
thanks in advance,
-Aaron



Relevant Pages

  • Re: efficient network transfer
    ... > i'm writing a proxy for file transfers. ... one client sends a file to the proxy which forwards it to ...
    (comp.lang.java.programmer)
  • Generating Proxy for Overloaded Web Service Functions
    ... writing a native C++/Win32 web service client. ... this when creating a proxy for a C++ client? ...
    (microsoft.public.dotnet.framework.webservices)
  • Re: ISA Server Problems, please help
    ... The All access rule for SBS Internet ... Web Proxy and/or ... > To accommodate the linux SecureNAT clients you should create a new Client ... ISA Server denies the specified Uniform Resource Locator. ...
    (microsoft.public.windows.server.sbs)
  • RE: Proxy requires authentication
    ... problem where it is being asked to authenticate to the proxy server. ... sure the problematic client also have Firewall Client installed. ... | Thread-Topic: Proxy requires authentication ...
    (microsoft.public.windows.server.sbs)
  • Re: Need to Turn Off Proxy Server in SBS 4.5
    ... client machines (it is done by default when you install an SBS client)? ... IE's web proxy settings are disabled like you said, ... Server is internal only...no outside web or ftp serving. ...
    (microsoft.public.backoffice.smallbiz)