java.io.IOException: 远程主机强迫关闭了一个现有的连接。
       at sun.nio.ch.SocketDispatcher.read0(Native Method)
       at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:25)
       at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:233)
       at sun.nio.ch.IOUtil.read(IOUtil.java:206)
       at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:236)
       at server.PlmsProtocol.handleRead(PlmsProtocol.java:59)
       at server.NetComm.StartService(NetComm.java:79)
       at server.NetComm.run(NetComm.java:29)
最近使用java.nio包写了一个服务器通信程序,在windows xp 下运行正常。可是移到windows 2000下当客户端连接上来的时候,收到数据时就报出这个异常,请教各位大虾们,这个问题怎么解决?处理接收数据的代码:
public  void handleRead(SelectionKey key) throws IOException {
        SocketChannel clntChan = (SocketChannel) key.channel();
        ByteBuffer buf = (ByteBuffer) key.attachment();
        //long bytesRead = clntChan.read(buf);
        int bytesRead = 0;
        try {
            bytesRead = clntChan.read(buf);
            nRecv = bytesRead;            if (bytesRead == -1) { // Did the other end close?
                handleClosed(clntChan);
                clntChan.close();
                buf.clear();
                return;
            } else if (bytesRead > 0) {
                // Indicate via key that reading/writing are both of interest now.
                key.interestOps(SelectionKey.OP_READ | SelectionKey.OP_WRITE);
                //key.interestOps(SelectionKey.OP_READ);
                return ;
            }
        } catch (NotYetConnectedException e) {
            e.printStackTrace();
            handleClosed(clntChan);
            return ;
        } catch (ClosedChannelException e) {
            e.printStackTrace();
            handleClosed(clntChan);
            return ;
        } /*catch(AsynchronousCloseException  e) {
        }
        catch(ClosedByInterruptException  e) {
        }*/ catch (IOException e) {
            e.printStackTrace();
            handleClosed(clntChan);
            return ;
        }
}