Results 1 to 4 of 4
- 11-19-2011, 06:27 AM #1
Member
- Join Date
- Nov 2011
- Posts
- 2
- Rep Power
- 0
Sending and recieving information from a server simultaneously
I'm trying to design a chat client that will be able to send messages to a server and receive messages simultaneously. Here is pseudo-code for what I have so far:
while(true){
System.out.print("What do you want to write to the server?:");
userInput = reader.readLine(); //line 3
writeToServer(userInput);
messagesFromServer = getServerMessages;
System.out.println("Server: "+messagesFromServer);
}
My problem is that my program will pause and wait for user input at line 3, and therefore messages from the server will not continuously stream in. My question: how can I design my chat client so that messages from the server are still displayed even when the program is waiting for user input?
-
Re: Sending and recieving information from a server simultaneously
Using separate threads comes immediately to mind.
- 11-19-2011, 03:35 PM #3
Member
- Join Date
- Nov 2011
- Posts
- 2
- Rep Power
- 0
Re: Sending and recieving information from a server simultaneously
Thanks for the reply. I'll read up on using separate threads in java
-
Re: Sending and recieving information from a server simultaneously
Similar Threads
-
sending and recieving files
By rav in forum New To JavaReplies: 9Last Post: 07-26-2010, 04:34 PM -
[SOLVED] Show Server and execution environment information
By mtyoung in forum JavaServer Pages (JSP) and JSTLReplies: 3Last Post: 02-04-2009, 05:22 AM -
Sending a Vector to TCP server
By eva in forum NetworkingReplies: 1Last Post: 01-02-2008, 10:34 AM -
Kwok Information Server 2.6.0
By JavaBean in forum Java SoftwareReplies: 0Last Post: 11-13-2007, 05:16 PM -
Kwok Information Server 2.3
By levent in forum Java SoftwareReplies: 0Last Post: 07-26-2007, 08:05 PM
Bookmarks