This week's book giveaway is in the Performance forum.
We're giving away four copies of The Java Performance Companion and have Charlie Hunt, Monica Beckwith, Poonam Parhar, & Bengt Rutisson on-line!
See this thread for details.
Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem with a messenger app: only one line is sent to remote address

 
Octavian Miu
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the server part is ok, when i am using telnet command i get in the app all the lines sent, but when i trying to sent from the app to app jus one line is catched by the app. Here is my client code. Please tell me what i m doing wrong:

public static void openClientSocket(String serverIP, MainWindow mainWindow) {
java.net.Socket clientSocket = null;
java.io.PrintWriter pw = null;

try {
clientSocket = new java.net.Socket(serverIP, 9995);
pw = new java.io.PrintWriter(clientSocket.getOutputStream());

pw.println(mainWindow.mainPanel.dialogPanel.inputField.getText());

pw.close();
clientSocket.close();
} catch (Throwable t) { System.out.println("Error " + t.getMessage());}
}
 
Joe Ess
Bartender
Posts: 9298
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the JavaRanch.
One common mistake is using println on a socket.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic