Socket not receiving data stream

I am new to programming sockets with Java and I have a few questions. My client connects to the server, however when I try to send just a simple string and display it on the server it doesn't work. I have seen several tutorials that all used different input/output stream classes, what is the suggested class to send string data? Below is my code: (Note: all exception handling was taken out for purposes of this post)

Server:

ServerSocket server =new ServerSocket(port,100);

System.out.println("Waiting for connection\n");

Socket connection = server.accept();

System.out.println("Connection received from: " + connection.getInetAddress().getHostName());

DataInputStream input =new DataInputStream(connection.getInputStream());

while(true)

{

String line = input.readLine();

System.out.println(line);

}

Client:

Socket client =new Socket(hostName,portNum);

DataOutputStream output =new DataOutputStream(client.getOutputStream());

output.writeBytes("Test");

Message was edited by:

jwarzech

[1426 byte] By [jwarzecha] at [2007-11-27 1:30:18]
# 1
dude include the statement below in the client code after writeBytesDataOutputStream output = new DataOutputStream(client.getOutputStream());output.writeBytes("Test");output.flush();check it out now
fahadaizaza at 2007-7-12 0:31:11 > top of Java-index,Core,Core APIs...
# 2
... and that will make no difference whatsover.The real problem is that you are trying to read a line, which is terminated by a line terminator, but you aren't writing a line terminator. So readLine() blocks waiting for the line terminator to arrive.
ejpa at 2007-7-12 0:31:11 > top of Java-index,Core,Core APIs...
# 3
Thanks for the help, I didn't even think about that. I guess it is sometimes the simple details that are the cause of headaches.
jwarzecha at 2007-7-12 0:31:11 > top of Java-index,Core,Core APIs...