Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / April 2005

Tip: Looking for answers? Try searching our database.

programming chat: get the messages back

Thread view: 
wanderin - 07 Apr 2005 22:17 GMT
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.
kjc - 07 Apr 2005 22:23 GMT
> 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.
[quoted text clipped - 16 lines]
>
> Thank you for helping.
Try sending the flush message to the output stream
wanderin - 08 Apr 2005 10:41 GMT
> > 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.
[quoted text clipped - 17 lines]
> > Thank you for helping.
> 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.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.