Solved

Java Client socket buffer overflow

Posted on 1997-03-18
1
1,093 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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Receive file in Servlet 1 36
json format text only 4 65
Modeling a class in java 5 32
java  and programming certification ? 4 65
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:

762 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

24 Experts available now in Live!

Get 1:1 Help Now