1

I am working with a android application in which I am wanting to share the file from one device to another through Wi-Fi. I am getting the speed of around 1.5 Mega Byte/s. Is there any way by which I can transfer the file by much higher data rate? Can you please tell why we are getting this less data rate even the devices and router is capable of handling more than 150Mbps (18.75MBps) data rate... Is it possible to use UFTP and will it be solving the purpose??

here is the code :

byte[] buf = new byte[2048];
try {
    int bytesRead = 0;
    while ((bytesRead = dis.read(buf, 0, buf.length)) != -1) {
        fLength = fLength - bytesRead;
        dos.write(buf, 0, bytesRead);
        Log.i("File Tranfer Thread", String.valueOf(fLength) + Thread.currentThread().getName());
        }
    }
}

Thanks

dbush
  • 205,898
  • 23
  • 218
  • 273
  • what kind of protocol do you use to transfert files? Are you using an app, or building an app? – jeorfevre May 13 '16 at 12:47
  • I am using own written code, that is tcp for transferring file over wifi... byte[] buf = new byte[2048]; try { int bytesRead = 0; while ((bytesRead = dis.read(buf, 0, buf.length)) != -1) { fLength = fLength - bytesRead; dos.write(buf, 0, bytesRead); Log.i("File Tranfer Thread", String.valueOf(fLength) + Thread.currentThread().getName()); } – Basudev Thakur May 16 '16 at 06:44

1 Answers1

0

Your code is fast.

There one thing you can try that worth the cost is playing with packet size. Try to modify the pack size in order to see the faster solution. Sometimes bigger packet is faster to send.

  1. packet size bigger byte[] buf = new byte[2048*10];
  2. packet size smaller byte[] buf = new byte[512];
  3. packet size 3 byte[] buf = new byte[2048*5];
jeorfevre
  • 2,286
  • 1
  • 17
  • 27