Skip to main content

using jxtasockets to transfer file(s) in jxta 2.3.3

3 replies [Last post]
magowiz
Offline
Joined: 2007-04-27
Points: 0

Hi all,
I'm trying to get a file transfer work in jxta 2.3.3 , the problem is that with a pdf file of 3.8 mb while the original file is ok, when I receive it on the other peer it's damaged.
The sender and the receiver code is in attachment

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
hamada
Offline
Joined: 2003-06-12
Points: 0

you have a bug in your code, you must invoke flush bos after the while loop to ensure all the data has been written out. also, the buffer is not really needed as JxtaSocket already provides internally buffers.

while ((numRead = in.read(buffer)) != -1) {
bos.write(buffer,0,numRead);
}
bos.flush()

hamada
Offline
Joined: 2003-06-12
Points: 0

one more thing, you really ought to be running JXTA 2.5 by now.

magowiz
Offline
Joined: 2007-04-27
Points: 0

I figured out what it was, I set erroneously the reliability flag to false in the sender socket, setting it to true solved the problem. Anyway I put also the flush invoke before closing.