Program enters infinite loop.
this is the first program i'm writing with sockets and is also a step towards making a chat application. my problem is that the program enters infinite loop.
package server;
import java.net.*;
import java.io.*;
class Server
{
publicstaticvoid main(String[] args)throws Exception
{
ServerSocket ss =new ServerSocket(9090);
Socket soc = ss.accept();
BufferedReader in =new BufferedReader(new InputStreamReader(soc.getInputStream()));
String str = in.readLine();
while(str!="")
{
System.out.println(str);
str = in.readLine();
}
soc.close();
ss.close();
}
}
this was the server - a seperate application. below is a part of the client - a seperate application
privatevoid jButton1ActionPerformed(java.awt.event.ActionEvent evt){
try
{
InetAddress ip = InetAddress.getByName("127.0.0.1");
Socket soc =new Socket(ip,9090);
PrintWriter out =new PrintWriter(new BufferedWriter(new OutputStreamWriter(soc.getOutputStream())),true);
str_out = jTextArea2.getText();
while(str_out!="")
{
out.println(str_out);
str_out = jTextArea2.getText();
}
soc.close();
}
catch(Exception e)
{
System.out.println("Error sending message");
}
}
privatevoid jButton2ActionPerformed(java.awt.event.ActionEvent evt){
str_out ="";
jTextArea2.setText(str_out);
}
when i press button send (jButton1) the text from the text area jTextArea2 is supposed to go to the server and then the server should display it in its out put screen. i tried sending hello and the server went on printing hello continously.
pleas help.

