applet不允许访问非安全的主机(只能是那个web服务器)

解决方案 »

  1.   

    Socket or ServerSocket的setSotimeout(int)是这样用的
    设置了Sotimeout参数,如你设置的s.setSoTimeout(10000);
    是从一输入流中读取数据,此时阻塞,当读了10s后,如没有读到,就会产生一个
    InterruptedIOException异常。一定要捕获他,read方法就可以返回了。
    一般可以这样写:
    while(true){
    try{
    //read data and others methods
    }
    catch(InterruptedIOException ioe){}
    }
    放在一个循环里,读超时,捕获InterruptedIOException,返回到循环再读下一次。
    你部获得IOException是InterruptedIOException的超类,其实你想捕获SocketException的,他也是IOException的超类,无意中捕获了InterruptedIOException,但是是在while(more){}的外面捕获,所以10s后没有数据,就出现error:....了。
    明白了吗?