Java Sockets and TCP Configuration

I am trying to create a file transfer application in Java, with an applet as a client and a standalone java application as a server (on a dedicated computer hosted in a datacenter). I am using DataOutputStream / DataInputStream to transfer data from both sides. When I send large amounts of data, the bandwidth is very volatile: at first everything is fine, then the tcp stream freezes for 40-50 seconds until nothing is transmitted, and then it starts over again.

When I look at the tcp stream from Ethereal I see duplicates, fast retransmissions and tcp retransmissions. But I don't think the problem comes from Java: I have the same problem with FTP transfers in FileZilla. But ... when I try to transfer data using netcat (netcat client + netcat server) everything is fine, the bandwidth is stable, the lost tcp packets seem to be retransmitted without pause, regardless of the transferred amount.

I like it if Java isn't as talented as netcat to play with tcp streams ...

I tried to play with Socket.setSendBufferSize (), but I didn't see any difference. Any idea?

Thank! And sorry for my bad english ...

+2


source to share


2 answers


Mr. amischiefr is right! This is the same problem as on the other topic. My problem was solved by replacing DataXXXputStream with BufferedXXXputstream. The write (byte [], off, len) methods are the same, and the doc does not talk about such different behavior. DataOutputStream is buffered, BufferedOutputStream too, but the second does it much better. Thank!



+1


source


Sounds more like your network is bogged down and you see a TCP window (which I believe is the correct term) is basically limiting your bandwidth.



0


source







All Articles