programming chat: get the messages back

W

wanderin

I try to program a chat, and I can send the message to the server.
But, unfortunately, my server can't send back the message it received.
Althought I put the necessary code, I think:

try{
BufferedReader recep = new BufferedReader(
new
InputStreamReader(SOCK.getInputStream()));

while (true){
String message = recep.readLine();
OUT_BUF.println(message);
}
}

I notify the OUT_BUF parameter refers to the PrintWriter class.
As you can see, the message received should be returned to the
clients.

Thank you for helping.
 
K

kjc

wanderin said:
I try to program a chat, and I can send the message to the server.
But, unfortunately, my server can't send back the message it received.
Althought I put the necessary code, I think:

try{
BufferedReader recep = new BufferedReader(
new
InputStreamReader(SOCK.getInputStream()));

while (true){
String message = recep.readLine();
OUT_BUF.println(message);
}
}

I notify the OUT_BUF parameter refers to the PrintWriter class.
As you can see, the message received should be returned to the
clients.

Thank you for helping.
Try sending the flush message to the output stream
 
W

wanderin

kjc said:
Try sending the flush message to the output stream

I tried to give the flush() method, but it still doen't work. In fact,
I think the problem is my server program doesn't know where to send
the messages in its buffer. So, I have to tell him that by a method
such as a kind of:
send(new Socket(ip_to_send, port_of_ip_client));

As I want there are more than one client, I should create a public
method, called in the thread of my reading/sending messages.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top