Hi there,
I'm trying to make a program which listens to the client input stream by using socket programming and timer
but whenever timer executes.. it gets hanged
Please help me out
here is the code...
private void jButton1MouseClicked(java.awt.event.MouseEvent evt) {
// TODO add your handling code here:
try
{
ServerUserName=jTextField1.getText();
ss=new ServerSocket(5000);
jButton1.enable(false);
jTextArea1.enable(true);
jTextField2.enable(true);
Timer t=new Timer(2000, new ActionListener() {
public void actionPerformed(ActionEvent e) {
try
{
s=ss.accept();
InputStream is=s.getInputStream();
DataInputStream dis=new DataInputStream(is);
jTextArea1.append(dis.readUTF());
}
catch(IOException IOE)
{
}
catch(Exception ex)
{
setLbl(ex.getMessage());
}
}
});
t.start();
}
catch(IOException IOE)
{
}
}
Thanks in advance