def serve(socket) #:nodoc:
      header = read_header(socket)
      if check_header(header)
        if header['tcp_nodelay'] == '1'
          socket.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1)
        end
        begin
          write_header(socket, build_header)
          if latching?
            if @last_published_msg
              publish_msg(socket, @last_published_msg)
            end
          end
          loop do
            @last_published_msg = @msg_queue.pop
            publish_msg(socket, @last_published_msg)
          end
        rescue
          socket.shutdown
        end
      else
        socket.shutdown
        p "header check error: #{header}"
        raise 'header check error'
      end
    end
def serve(socket) #:nodoc:
      header = read_header(socket)
      if check_header(header)
        if header['tcp_nodelay'] == '1'
          socket.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1)
        end
        begin
          write_header(socket, build_header)
          if latching?
            if @last_published_msg
              publish_msg(socket, @last_published_msg)
            end
          end
          loop do
            @last_published_msg = @msg_queue.pop
            publish_msg(socket, @last_published_msg)
          end
        rescue
          socket.shutdown
        end
      else
        socket.shutdown
        p "header check error: #{header}"
        raise 'header check error'
      end
    end
this is called if a socket accept a connection.
 This is GServer's function
 @param [IO] socket given socket