请问大神,为什么编译的时候抛出异常
import java.net.*;
public class WS9 extends Thread{
static String s;
int port=8005;
InetAddress A;
MulticastSocket soc;
public WS9(){
try{
A=InetAddress.getByName("127,0,0,1");
soc=new MulticastSocket(port);
soc.joinGroup(A);
soc.setTimeToLive(2);
}
catch(Exception e2)
{}
}
public void run(){
for(int i=1;i<=11;i++)
try{
byte[] buf=s.getBytes();
DatagramPacket P1=new DatagramPacket(buf,buf.length,A,port);
soc.send(P1);
sleep(3000);
}
catch(Exception e3)
{}
soc.close();
}
public static void main(String[] args){
s=args[0];
new WS9().start();
}
}
你程序所有的异常自己都没有处理
另外,一个明显的错
A=InetAddress.getByName("127,0,0,1");
ip地址要用点不能用逗号的
还有,你概念错了,编译的时候不可能抛出异常的,是运行的时候
热门标签: