Basically, I want my client to be continously able to send messages to the server, but *also* at the same time be able to recevie and display any messages from the server. This is the loop I have in its current state on the client
It asks me to enter a message, I enter something and it sends it to the server.. perfect. BUT it just doesnt do anything after that, it just halts. I want it to print 'enter a message' again, and also be able to print messages from the server. Hope someone can help.Code:while (true) { try { System.out.println("Enter a message to send to the server:"); nextline = stdIn.readLine(); if (nextline != null) out.println(nextline); fromServer = in.readUTF(); if (fromServer != null) System.out.println("From server " + fromServer); else { out.close(); in.close(); csocket.close(); stdIn.close(); } } catch (Exception e) { } }




Reply With Quote