Solved

Java Client socket buffer overflow

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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

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…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

635 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