I am working on a chat client and I have created a registration Jframe where a user gets to register. when registering, it is supposed to connect to server so that server can check if the userid already exists or not. when I am creating a new socket it keeps giving me an error.
the code for the socket creation is:
try
{
String serverIP;
int Port = 5000;
Socket socks;
serverIP = String.valueOf(InetAddress.getLocalHost());
socks = new Socket(serverIP, Port);
InputStreamReader streamreader = new InputStreamReader(socks.getInputStream());
reader = new BufferedReader(streamreader);
writer = new PrintWriter(socks.getOutputStream());
writer.println(inputUsername + ":"+inputPassword+":"+inputConfirmPassword+":Register");
writer.flush(); // flushes the buffer
}
catch(IOException io)
{
System.err.println(io.getMessage()+"---connection error 1");
}
catch(SecurityException se)
{
System.err.println(se.getMessage()+"---connection error 2");
}
catch(IllegalArgumentException ae)
{
System.err.println(ae.getMessage()+"---connection error 3");
}
catch(NullPointerException ne)
{
System.err.println(ne.getMessage()+"---connection error 4");
}
when I execute, i get the following error:
Dell/172.16.3.24---connection error 1
this is generated by the IOException catch statement.
Can anyone tell me why this is happening and also how to rectify it?
thanks a lot.