This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
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: 8843
    
    7

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


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Problem with a messenger app: only one line is sent to remote address
 
Similar Threads
Multithread-call center support
Networked programing code
Problem in using PrintWriter.print() method
Multichat Application
Multiple client chat server