dockets and readLine()

Posted on 1998-10-15
Last Modified: 2012-06-21
if DataInputStream.readLine block until char(13) , and i"m using sockets for communiction so if client and server coming both to readline(), then all the proccess stack , right?
for some reasone my comunication between the client and the server get stuck after a few msg dialog ,any other idea ?
how can i solv it ?
10x in advance
Question by:asi
  • 3
  • 2

Author Comment

ID: 1225840
does a communication with sockets and stream inforce order between the client and the server (i.e :one sentence server and one client ) ?

Author Comment

ID: 1225841
if the answer to the last comment is yes ? what is the oaltrnative to un order connection ?

Expert Comment

ID: 1225842
Can you explain what you are doing a bit more....

I assume you communication protocol is failing..?

If you are writing a clinet/server app both the client and the server must know what data to expect.. (protocol)

For example.. if you send 2 strings to the client (from the server) the client must know how many string to retrieve..


client reads how many and expects that many..

for(int i=0;i<how_many;i++)

string1 = dis.readUTF();
string1 = dis.readUTF();
string_n = dis.readUTF();


I'm not sure what your problem is though.. can u explain it som more..

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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.


Expert Comment

ID: 1225843
You have to define your custom message system. In the most simple case it should be something like this:

//Control line
Line1 : "DO X, DATA N"
Next N lines contain data

When the server (or the client) receives a control line, it knows what to read afterwards. Also, it is good the communication to be, from the type,
request, response, request, response,....

so, it won't hapen bot the server and the client to wait for a request (or responce) simultaneously, which case they'll both block.

Another solution. Make two channels, outgoing and incomming, preferably in separate threads. this way you will be able to send , while waiting and receive while sending. this is especially valid for the server.


Author Comment

ID: 1225844
change your statuse to answer
and i'll give u the pointe
(i find some other solution , every time client or server receive somthing he should send immeditli "ping " one direction msg (in case that there is nothing else in the outgoing line
but u desever the points   ...


Accepted Solution

diakov earned 50 total points
ID: 1225845
sure. you're welcome.


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
numbers ascending pyramid 101 212
Weekend adv creator 3 52
netstat -ano | find "8000" and taskkill /f /pid 2984 3 83
What's wrong with this code? 4 26
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…
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 “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
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…

860 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