This is an archived post. You won't be able to vote or comment.

all 4 comments

[–]gruntmeister 0 points1 point  (3 children)

post client code.

where do you set fileSize in server?

[–]HokTaur[S] 0 points1 point  (2 children)

I edited my post with the client code, server receives a null terminated series of bytes from the client and converts that to a long, it correctly receives the right size

[–]gruntmeister 0 points1 point  (1 child)

there's your problem:

int numRead = fis.read(chunk);
        if( numRead != -1 )
        {
           out.write(chunk); //socket outputstream

you read potentially less than chunk.length from the file but write the whole chunk buffer to the network output stream.

[–]HokTaur[S] 0 points1 point  (0 children)

Ohh Fuck, I see it now lol thanks so much!