Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

chat server with receiving problem

843807May 29 2003 — edited May 29 2003
problem: I have no idea how to get around this problem...
			while(true) {
/*chat section begin*/		if (newMessage) {					//if a newMessage flag is set
					System.out.println("new Message set " +id);	//print the id of computer receiving and that it entered if, serverside
					os.println(cMessage);				//output the message to printwriter,clientside
					newMessage=false;				//set the newMessage flag to false
					os.flush();					//flush printwriter
				}
/*chat section end*/						
				System.out.println("outside the chat loop");		//outside of the above if statment
				String inLine=is.readLine();				/*At this point all function stops and it may not receive any messages... i have no idea how to fix this*/
				System.out.println(inLine);				//print message serverside
				if	(inLine.length()>0)				//checks if the client input is of decent length
					outLine	=  processInput(inLine);		//sends input to method that returns the server responses
				else
					outLine=processInput("");			//if the inLine was crappy, send blank line back (later change to "invalid")
				os.println(outLine);					//print to printwriter
				os.flush();						//flush
				//old chat section position
				if(outLine.equals("/close"))				//if the server output is close, break connection
				break;							//breaking
			}
			//clean	up
			os.close();
			is.close();
			client.close();
		}
full code and tMessage source is located at:
http://www.angelfire.com/alt/grosslax/snet.java
http://www.angelfire.com/alt/grosslax/tMessage.java
I realize that this code is also very rustic and not the best way of doing things, any help to superior ideas would be appreciated
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 26 2003
Added on May 29 2003
1 comment
97 views