Solved

Java Client socket buffer overflow

Posted on 1997-03-18
1
1,145 Views
Last Modified: 2006-11-17
null
0
Comment
Question by:akrebs
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
going to wrong jsp page 2 47
add projects t working set in maven 2 40
Why is enum singleton a better approach than static factory 3 50
program arguments vs VM arguments 4 28
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…
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 how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
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.

756 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