• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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());}
}
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the JavaRanch.
One common mistake is using println on a socket.
 
I'm thinking about a new battle cry. Maybe "Not in the face! Not in the face!" Any thoughts tiny ad?
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic