1. public class ProtoBufServerHandler extends ChannelInboundHandlerAdapter {
    2. @Override
    3. public void channelRead(ChannelHandlerContext ctx, Object msg)
    4. throws Exception {
    5. PersonProto.Person req = (PersonProto.Person)msg;
    6. System.out.println("get data name = "+req.getName());
    7. }
    8. @Override
    9. public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
    10. if(cause instanceof IOException){
    11. System.out.println("远程客户端强迫关闭了一个现有的连接。");
    12. }
    13. ctx.close();
    14. }
    15. }