ideas/SimpleClient.java
public void talk (Scanner receiver, PrintWriter transmitter) {
		// print a message
		System.out.println( "Connected!\n"+getClientAddress()+":"+getClientPort()+" <-> "+getServerAddress()+":"+getServerPort() );

		// chat loop
		Scanner stdin = new Scanner( System.in );
		String fromServer;
		String toServer;
		while (true) {
			// get a line from the command line
			System.out.print( " > " );
			toServer = stdin.nextLine();
			// break loop if the line "exit" is entered
			if (toServer.toLowerCase().equals("exit")) break;
			// transmit the line to the server
			transmitter.println( toServer );
			// break the loop if there was an error sending the message
			if (transmitter.checkError()) {
				System.out.println( "Error sending message!" );
				break;
			}
			// wait for a line from the server
			if (receiver.hasNextLine()) {
				fromServer = receiver.nextLine();
				System.out.println( "   "+fromServer );
			}
		}
		// if we break the loop, tell the user that we're disconnecting
		System.out.print( "Disconnecting from server "+server_address+":"+server_port+".\n\n" );
	}
// this is the method that defines the protocol of how data is exchanged

this is the method that defines the protocol of how data is exchanged
this is the method that defines the protocol of how data is exchanged
public void talk (Scanner receiver, PrintWriter transmitter) {
		System.out.println( "Connected!\n"+getClientAddress()+":"+getClientPort()+" <-> "+getServerAddress()+":"+getServerPort() );
		Scanner stdin = new Scanner( System.in );
		String fromServer;
		String toServer;
		while (true) {
			System.out.print( " > " );
			toServer = stdin.nextLine();
			if (toServer.toLowerCase().equals("exit")) break;
			transmitter.println( toServer );
			if (transmitter.checkError()) {
				System.out.println( "Error sending message!" );
				break;
			}
			if (receiver.hasNextLine()) {
				fromServer = receiver.nextLine();
				System.out.println( "   "+fromServer );
			}
		}
		System.out.print( "Disconnecting from server "+server_address+":"+server_port+".\n\n" );
	}
public void talk ( Scanner receiver , PrintWriter transmitter ) { System . out . println ( "Connected!\n" + getClientAddress ( ) + ":" + getClientPort ( ) + " <-> " + getServerAddress ( ) + ":" + getServerPort ( ) ) ; Scanner stdin = new Scanner ( System . in ) ; String fromServer ; String toServer ; while ( true ) { System . out . print ( " > " ) ; toServer = stdin . nextLine ( ) ; if ( toServer . toLowerCase ( ) . equals ( "exit" ) ) break ; transmitter . println ( toServer ) ; if ( transmitter . checkError ( ) ) { System . out . println ( "Error sending message!" ) ; break ; } if ( receiver . hasNextLine ( ) ) { fromServer = receiver . nextLine ( ) ; System . out . println ( "   " + fromServer ) ; } } System . out . print ( "Disconnecting from server " + server_address + ":" + server_port + ".\n\n" ) ; }
this is the method that defines the protocol of how data is exchanged
this is the method that defines the protocol of how data is exchanged
// print a message
 // chat loop
 // get a line from the command line
 // break loop if the line "exit" is entered
 // transmit the line to the server
 // break the loop if there was an error sending the message
 // wait for a line from the server
 // if we break the loop, tell the user that we're disconnecting
