The server and client are connected and chatting?
Quote:
Originally Posted by cwl157
Here is the Server class's receive method that I have been working on but does not work. I thought if this could return what is received as a String then that String could be passed into the send method and sent to all the clients. I just hangs when receive is hit.
private static String receive() throws IOException { String test = ""; try { test = (String)input.readObject(); System.out.print("\n" + test); } // end try catch(ClassNotFoundException classNotFoundException) { System.out.print("\nUnknown object recieved"); } // end catch return test; } // end receive
|
Well, that method is where the server accepts incoming data. Yeah, test is a lousy name now that I think of it.
For sending data, for both the client and the server, why don't you use the send method? When ever you want to send data from either, you just call the method with the info as an argument.
public Client c
c = new Client();
c.connect();
c.streams().
c.processConnection();
... a lot of code later ...
c.sendData("5, 8");
You can put the sendData call in the same method that gets the input from the user, so the data is sent to the server and send back and to the other client.