Solved

dockets and readLine()

Posted on 1998-10-15
6
308 Views
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
asi
0
Comment
Question by:asi
  • 3
  • 2
6 Comments
 

Author Comment

by:asi
Comment Utility
does a communication with sockets and stream inforce order between the client and the server (i.e :one sentence server and one client ) ?
0
 

Author Comment

by:asi
Comment Utility
if the answer to the last comment is yes ? what is the oaltrnative to un order connection ?
0
 
LVL 1

Expert Comment

by:ramsay
Comment Utility
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..

dos.writeInt(how_many)
dos.writeUTF(string1);
dos.writeUTF(string2);
dos.writeUTF(string_n);

client reads how many and expects that many..

dis.readInt(how_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..

0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 8

Expert Comment

by:diakov
Comment Utility
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.

Cheers.
0
 

Author Comment

by:asi
Comment Utility
diakov
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   ...
10x
asi

0
 
LVL 8

Accepted Solution

by:
diakov earned 50 total points
Comment Utility
sure. you're welcome.

0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
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:
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

743 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

8 Experts available now in Live!

Get 1:1 Help Now