Click here to Skip to main content
15,905,593 members
Home / Discussions / Java
   

Java

 
AnswerRe: Java strings Pin
Gerry Schmitz6-Dec-23 7:50
mveGerry Schmitz6-Dec-23 7:50 
Question<pre>Problems enlarging Eclipse icons Pin
BrunoV202219-Nov-23 10:57
BrunoV202219-Nov-23 10:57 
AnswerRe: <pre>Problems enlarging Eclipse icons Pin
jschell5-Dec-23 5:27
jschell5-Dec-23 5:27 
QuestionHow to convert string to double with trailing zeros after decimal Pin
Member 161354338-Nov-23 1:46
Member 161354338-Nov-23 1:46 
AnswerRe: How to convert string to double with trailing zeros after decimal Pin
Richard MacCutchan8-Nov-23 2:07
mveRichard MacCutchan8-Nov-23 2:07 
GeneralRe: How to convert string to double with trailing zeros after decimal Pin
Member 161354338-Nov-23 2:23
Member 161354338-Nov-23 2:23 
GeneralRe: How to convert string to double with trailing zeros after decimal Pin
Richard MacCutchan8-Nov-23 2:35
mveRichard MacCutchan8-Nov-23 2:35 
GeneralRe: How to convert string to double with trailing zeros after decimal Pin
Dave Kreskowiak8-Nov-23 3:20
mveDave Kreskowiak8-Nov-23 3:20 
GeneralRe: How to convert string to double with trailing zeros after decimal Pin
jschell8-Nov-23 6:12
jschell8-Nov-23 6:12 
AnswerRe: How to convert string to double with trailing zeros after decimal Pin
Ralf Meier8-Nov-23 8:02
mveRalf Meier8-Nov-23 8:02 
AnswerRe: How to convert string to double with trailing zeros after decimal Pin
Dave Kreskowiak8-Nov-23 2:23
mveDave Kreskowiak8-Nov-23 2:23 
QuestionHow to use JNI without setting Environment Variables Pin
Valentinor16-Oct-23 0:54
Valentinor16-Oct-23 0:54 
AnswerRe: How to use JNI without setting Environment Variables Pin
Valentinor16-Oct-23 1:42
Valentinor16-Oct-23 1:42 
AnswerRe: How to use JNI without setting Environment Variables Pin
jschell16-Oct-23 4:58
jschell16-Oct-23 4:58 
GeneralRe: How to use JNI without setting Environment Variables Pin
Valentinor16-Oct-23 5:41
Valentinor16-Oct-23 5:41 
GeneralRe: How to use JNI without setting Environment Variables Pin
jschell17-Oct-23 5:47
jschell17-Oct-23 5:47 
GeneralRe: How to use JNI without setting Environment Variables Pin
Valentinor17-Oct-23 19:26
Valentinor17-Oct-23 19:26 
QuestionSending file though socket as byte[] Pin
JohnCodding25-Sep-23 20:52
JohnCodding25-Sep-23 20:52 
GeneralRe: Sending file though socket as byte[] Pin
JohnCodding25-Sep-23 21:33
JohnCodding25-Sep-23 21:33 
GeneralRe: Sending file though socket as byte[] Pin
Richard MacCutchan25-Sep-23 22:32
mveRichard MacCutchan25-Sep-23 22:32 
GeneralRe: Sending file though socket as byte[] Pin
JohnCodding25-Sep-23 23:44
JohnCodding25-Sep-23 23:44 
Richard MacCutchan wrote:
I was looking at this code earlier and wondered why you sent the buffer size after the data. It makes much more sense to send the size first.

Because when they are used it doesn't matter the order they were sent, I didn't even think about that.
Richard MacCutchan wrote:
Also there is no point in sending 8192 bytes if you have only read one byte from the input file. So only send the amount of data that has been read.

I changed that now on client: dataOut.writeObject(Arrays.copyOf(buffer, sizeRead));

What about buffer = new byte[8192]; I added, is that how it should be done to send now data each time?
Java
dataOut.writeObject(true);
dataOut.writeObject(sizeRead);
dataOut.writeObject(Arrays.copyOf(buffer, sizeRead));
dataOut.flush();
buffer = new byte[8192];

Richard MacCutchan wrote:
Tuning TCP performance is not an exact science unfortunately, but you can find plenty of discussions of the subject on the internet.

From what I've seen they suggest two things most of the time:
1. Setting socket.setTcpNoDelay(true);. I tried that on both client and server bust still no use;
2. Using BufferedOutputStream/BufferedInputStream inside ObjectOutputStream/ObjectInputStream, but still the same 3 MB/s. Even after combining 1. and 2.
GeneralRe: Sending file though socket as byte[] Pin
Richard MacCutchan25-Sep-23 23:58
mveRichard MacCutchan25-Sep-23 23:58 
GeneralRe: Sending file though socket as byte[] Pin
JohnCodding26-Sep-23 0:53
JohnCodding26-Sep-23 0:53 
GeneralRe: Sending file though socket as byte[] Pin
jschell3-Oct-23 4:42
jschell3-Oct-23 4:42 
GeneralRe: Sending file though socket as byte[] Pin
JohnCodding12-Oct-23 23:35
JohnCodding12-Oct-23 23:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.