aspose file tools*
The moose likes Sockets and Internet Protocols and the fly likes Problem with a messenger app: only one line is sent to remote address Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "Problem with a messenger app: only one line is sent to remote address" Watch "Problem with a messenger app: only one line is sent to remote address" New topic
Author

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

Octavian Miu
Greenhorn

Joined: May 22, 2009
Posts: 8
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

Joined: Oct 29, 2001
Posts: 8997
    
    9

Welcome to the JavaRanch.
One common mistake is using println on a socket.


[How To Ask Questions On JavaRanch]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem with a messenger app: only one line is sent to remote address