create or replace and compile java source named clientsocket as
import java.io.*;
import java.net.*;
public class ClientSocket {
static int result=0;
public static void main(String args[]){
ClientSocket sc=new ClientSocket();
sc.sendmessage();
}
public static int sendmessage(){
try{
Socket s = new Socket("192.68.69.96", 8111); result=1;
}
catch(SecurityException e){
result=2;
System.out.println("securityexception when connecting server!");
}
catch(IOException e){
result=3;
System.out.println("ioexception when connecting server!");
}
return result;
}
} 运行结果result=2,在这里不让我创建Socket,问题出在哪呢?
import java.io.*;
import java.net.*;
public class ClientSocket {
static int result=0;
public static void main(String args[]){
ClientSocket sc=new ClientSocket();
sc.sendmessage();
}
public static int sendmessage(){
try{
Socket s = new Socket("192.68.69.96", 8111); result=1;
}
catch(SecurityException e){
result=2;
System.out.println("securityexception when connecting server!");
}
catch(IOException e){
result=3;
System.out.println("ioexception when connecting server!");
}
return result;
}
} 运行结果result=2,在这里不让我创建Socket,问题出在哪呢?
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货