<commit_before>#--
# Copyright (C)2007 <NAME>
# You can redistribute this under the terms of the Ruby license
# See file LICENSE for details
#++

require 'socket'

module Rev
  # Listeners wait for incoming connections.  When a listener receives a
  # connection it fires the on_connection event with the newly accepted
  # socket as a parameter.
  class Listener < IOWatcher
    def initialize(listen_socket)
      @listen_socket = listen_socket
      super(@listen_socket)
    end

    # Returns an integer representing the underlying numeric file descriptor
    def fileno
      @listen_socket.fileno
    end

    # Close the listener
    def close
      detach if attached?
      @listen_socket.close
    end

    # Called whenever the server receives a new connection
    def on_connection(socket); end
    event_callback :on_connection

    #########
    protected
    #########

    # Rev callback for handling new connections
    def on_readable
      begin
        on_connection @listen_socket.accept_nonblock
      rescue Errno::EAGAIN
        STDERR.puts "warning: listener socket spuriously readable"
      end
    end<commit_msg>listener: remove warning about spuriously readable sockets<commit_after>#--
# Copyright (C)2007 <NAME>
# You can redistribute this under the terms of the Ruby license
# See file LICENSE for details
#++

require 'socket'

module Rev
  # Listeners wait for incoming connections.  When a listener receives a
  # connection it fires the on_connection event with the newly accepted
  # socket as a parameter.
  class Listener < IOWatcher
    def initialize(listen_socket)
      @listen_socket = listen_socket
      super(@listen_socket)
    end

    # Returns an integer representing the underlying numeric file descriptor
    def fileno
      @listen_socket.fileno
    end

    # Close the listener
    def close
      detach if attached?
      @listen_socket.close
    end

    # Called whenever the server receives a new connection
    def on_connection(socket); end
    event_callback :on_connection

    #########
    protected
    #########

    # Rev callback for handling new connections
    def on_readable
      begin
        on_connection @listen_socket.accept_nonblock
      rescue Errno::EAGAIN
      end
    end
{'fraction_non_alphanumeric': 0.0605658709106985, 'fraction_numerical': 0.0035366931918656055, 'mean_word_length': 3.026690391459075, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7206123', 'n_tokens_mistral': 609, 'n_tokens_neox': 580, 'n_words': 229}