Solved

Java Client socket buffer overflow

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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Suggested Solutions

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
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 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 …
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:

777 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