Hi folks!
I have written an EchoServer that responds with the String ack if the data have been send accordingly.
My client looks like this... In order to receive the ack answer from the server the "echoSocket" puts the received data into in, my ObjectInputStream. Only if I comment these parts out the client works
echoSocket = new Socket(server_name, tcp_port);
System.out.println(" *** Connected to " + server_name + " ***");
System.out.println("Press Enter to send your message.");
out = new ObjectOutputStream(echoSocket.getOutputStream());
in = new ObjectInputStream(echoSocket.getInputStream());
out.flush();
String message = System.console().readLine();
while(!message.equals("quit")) {
// problem
if (in.readObject().equals(ack))
System.out.println("ACKed");
in.close();
// problem ends
out.flush();
out.writeObject(message);
System.out.println("Sending: " + message);
message = System.console().readLine();
out.flush();
}
Does anybody know why it won't send my Strings?
Thanks, Marius