Solved

Java Client socket buffer overflow

Posted on 1997-03-18
1
1,107 Views
Last Modified: 2006-11-17
null
0
Comment
Question by:akrebs
1 Comment
 

Accepted Solution

by:
heistad earned 150 total points
ID: 1219063
The Socket class implements a TCP/IP connection to your server. TCP guarantees that all of the data sent on this connection is delivered _reliably_ in the order it was sent. For information to be 'lost or misordered' would mean that the TCP ordering and/or the reliablity guarantees are breaking down. This seems unreasonable as everyone would be screaming that the Socket class is broken. Your problem is most likely someplace else.

The Socket class is based on native sockets which are highly platform dependent. If you look at the JDK implementation of Socket you will find that the io methods directly call native code. This is why you won't find an interface to change the queue size of a Socket; there is no defined standard across platforms to change this. In fact I'm not sure that the majority of platforms provide a way to change this :)

You cannot speed up the socket itself, but you can speed up your code. I think that you can get rid of the buffered input stream as the native socket would be doing its own internal buffering. I suspect that this stream is internally allocating memory, which among other things in Java, is very slow :) . Furthermore DataInputStreams (and output) are very slow. You will get a great increase in speed if you don't use these. You could use a byte(or possibly add or multiply the first X bytes off the socket together if you are desperate) to indicate the size, but then you would be limited to byte sized records(or a multiple of byte size records).

I hope this helps. If it doesn't post or mail some code and I'll take a deeper look.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now