public static void test_socket(){
String host="localhost ";
for (int i=0;i<50;i++){
try{
Socket sc=new Socket(host,i);
System.out.prin tln("There is a server at port "+i+" ");
}
catch(UnknownHo stException e){
System.out.prin tln("Host There is an error at port "+i+" ");
}
catch(IOExcepti on e){
System.out.prin tln("IO There is an error at port "+i+" ");
}
}
}
I just copied and executed theses codes from the net...
All the times ,I am getting the IOException ....What's the problem with my codes,Why am I getting this exception all the time???
Thanks in adv
String host="localhost ";
for (int i=0;i<50;i++){
try{
Socket sc=new Socket(host,i);
System.out.prin tln("There is a server at port "+i+" ");
}
catch(UnknownHo stException e){
System.out.prin tln("Host There is an error at port "+i+" ");
}
catch(IOExcepti on e){
System.out.prin tln("IO There is an error at port "+i+" ");
}
}
}
I just copied and executed theses codes from the net...
All the times ,I am getting the IOException ....What's the problem with my codes,Why am I getting this exception all the time???
Thanks in adv
Comment