HI I hope I can get some help on this :
I have a class called protocol in which i specify the appearance and what each selection does and I have this class called :
public class Client
{
private boolean status = true;
private PrintWriter out = null;
private BufferedReader in = null;
private Socket assignSocket = null;
private
String host;
public static void main(String[] args) throws IOException
{
Client cc = new Client();
cc.runClient(args);
}
private void runClient(String[] args) throws IOException
{
if (args.length == 0)
{
host = "localhost";
}
else
{
host = args[0];
}
try
{
assignSocket = new Socket("localhost", 4444);
out = new PrintWriter(assignSocket.getOutputStream(), true);
in = new BufferedReader(new InputStreamReader
(assignSocket.getInputStream()));
}
catch (UnknownHostException e)
{
System.err.println("Doesn't know about host: " + host);
e.printStackTrace();
return;
}
catch (IOException e)
{
System.err.println("Couldn't get I/O for the connection to: " +
host);
e.printStackTrace();
return;
}
BufferedReader stdIn = new BufferedReader(new InputStreamReader
(System.in));
String fromServer;
String fromUser = null;
while (true)
{
fromServer = in.readLine();
System.out.println(fromServer);
while (true)
{
fromServer = in.readLine();
if (fromServer == null)
{
System.out.println("fromServer was null");
break;
}
System.out.println(fromServer);
if (fromServer.equals("Bye"))
{
status = false;
break;
}
}
if (status == false)
{
break;
}
if (fromUser != null)
{
fromUser = stdIn.readLine();
out.println(fromUser);
}
}
out.close();
in.close();
stdIn.close();
assignSocket.close();
}
}
I think part of my problem is I can't break out of the loop but... i am not sure what i am doing wrong or omitting.
any suggestions would be great.
valarie