socket设置setsotimeout后为什么没有作用?

    try {
        ServerSocket serverSocket=null;
        serverSocket=new ServerSocket(1989);
        Socket socket=serverSocket.accept();
        serverSocket.setSoTimeout(2000);
        int temp=0;
        String chan_name;
        long chan_id;
        int chan_lock;
        int chan_skip;
        long chan_group;
        byte[] buf = new byte[1024*4];

        while(true){
            // socket.setSoTimeout(1000);

try {
InputStream ipInputStream=socket.getInputStream();
while((temp=ipInputStream.read(buf))!=-1){

    try {
        JSONObject prodate;
        String recStr = new String(buf, 0,
                temp);
        prodate = new JSONObject(recStr);
         chan_name = prodate.getString("mservice_name");
         chan_id = prodate.getLong("prog_id");
         chan_lock=prodate.getInt("mlock_flag");
         chan_skip=prodate.getInt("mskip_flag");
         chan_group=prodate.getLong("mfav_group");
        if(chan_name.contains(".")){
        StringBuffer tmp2 = new StringBuffer(chan_name);
        Bundle bundle = new Bundle();

// bundle.putString("chan_index",
// tmp2.substring( tmp2.indexOf(".")-1, tmp2.indexOf(".")));
//Log.d(TAG, "chan_index: " + tmp2.substring(0, tmp2.indexOf(".")));
bundle.putString("chan_name",tmp2.substring(tmp2.indexOf(".")+1));
bundle.putLong("chan_id", chan_id);
bundle.putInt("chan_lock", chan_lock);
bundle.putInt("chan_skip", chan_skip);
bundle.putLong("chan_group", chan_group);
Log.d(TAG, "chan_name: " + tmp2.substring(tmp2.indexOf(".")+1));
msg = chanHandler.obtainMessage();
msg.setData(bundle);
msg.what = 1;
chanHandler.sendMessage(msg);
}
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

    }

} catch (SocketTimeoutException e) {
// TODO: handle exception
Log.d(TAG, "scan server timeout... ");
msg = chanHandler.obtainMessage();
msg.what = 0;
chanHandler.sendMessage(msg);
}
catch(SocketException e){

e.printStackTrace();

} catch (Exception e) {

e.printStackTrace();

}

        }

            }


        catch (Exception e) {
        Log.e(TAG, e.getLocalizedMessage());
    }

来个大神帮帮忙啊,一直catch不到超时的动作。

超时时间是不是太短了,系统有一个自己的缺省超时设置,30s左右

我遇到和楼主一样的问题,请问楼主知道原因了吗。很急啊。。。大作业卡在这里了

是不是没有异常抛出啊?这个参数只是读数据阻塞的时间,读到了就会正常走下去不会抛异常。