Network file transfer
metalstorm
metalheadstorm at gmail.com
Tue Oct 11 15:26:11 EDT 2011
ok ive tried:
'ChanneBuffers.wrappedBuffers(byte[])'
I get corrupted data on the client end.
using a dynamic buffer
private final ChannelBuffer buf = new DynamicChannelBuffer(1024 * 8);
FileInputStream in = new FileInputStream(myFile);
byte[] buffer = new byte[1024 * 8];
int read = 0;
int totalRead = 0;
System.out.println("file size: " + myFile.length());
while ((read = in.read(buffer, 0, buffer.length)) > 0)
{
buf.writeBytes(buffer, 0, read);
// ch.write(ChannelBuffers.wrappedBuffer(buffer, 0, read));
ch.write(buf);
totalRead += read;
System.out.println("read: " + read);
System.out.println("totalread: " + totalRead);
}
which seems to give me double the file on client end, so if the file
contained 1234 i would get 12341234
im using Normans code with
FileOutputStream out = new FileOutputStream("fileToSend.txt", true);
I find it has to be set to true otherwise the file is only 1 buffer size big
Sample debugging data:
Server:
got file: fileToSend.txt
file size: 8206
read: 8192
totalread: 8192
read: 14
totalread: 8206
Client (line.length):
has array: 1024
has array: 2048
has array: 2048
has array: 3072
has array: 4096
has array: 4124
to save your maths, = 16412 = (8206 x 2)
I don't see how it receiving 2x the data when on 1 x is sent?
--
View this message in context: http://netty-forums-and-mailing-lists.685743.n2.nabble.com/Network-file-transfer-tp6875434p6882322.html
Sent from the Netty User Group mailing list archive at Nabble.com.
More information about the netty-users
mailing list