[xSocket-develop] ExtendedClosedChannelException
Status: Inactive
Brought to you by:
grro
From: 王普 <wa...@ho...> - 2010-02-23 09:02:32
|
Client: import java.io.IOException; import java.net.InetSocketAddress; import org.xsocket.connection.BlockingConnection; import org.xsocket.connection.IBlockingConnection; public class UserClientTest { public static void main(String[] args) throws IOException { InetSocketAddress address = new InetSocketAddress("10.88.132.69", 32111); IBlockingConnection bc = new BlockingConnection(address.getHostName(), address.getPort()); String req = "hello"; bc.write(req + "\r\n"); bc.flush(); String s = bc.readStringByDelimiter("\r\n"); System.out.println(s); } } Server-Handler: public boolean onData(INonBlockingConnection nbc) throws IOException, BufferUnderflowException, ClosedChannelException, MaxReadSizeExceededException { String data = nbc.readStringByDelimiter("\r\n"); if (data.equals("")) nbc.write(Constant.RESULT + Constant.FAILURE + "\r\n"); else nbc.write(Constant.RESULT + Constant.SUCCESS + "\r\n"); nbc.flush(); return true; } sometimes ExtendedClosedChannelException wil occur,sometimes not occur. I am so surprise. If you can help me, thank you very much! |