hi everyone,
iam trying to connect to server here is the code for connecting:
public void CONNECT_TO()
{
int port=200;
if(t1.getText()=="")
serv="localhost";
else
serv=t1.getText();
try
{
port = Integer.parseInt(t2.getText());
}
catch (Exception e) { }
try
{
c_s = new Socket(serv, port);
l3.setText("Connected to server " +c_s.getInetAddress()+":" +c_s.getPort());
form F=new form();
F.show();
F.setResizable(false);
this.hide();
}
catch (UnknownHostException e)
{
System.out.println(e);
System.out.println("Error in connecting Server");
}
catch (IOException e)
{
System.out.println(e);
System.out.println("Error");
}
}
It runs fine but when i enter localhost for ip address it gives me the error for the second exception, IOEXCEPTION.
anyone knows why?
thank you