Sha256: f84411507f7797a53d8d0b6923439e8de97e49ffe063eea730e325b81a9b877a

Contents?: true

Size: 620 Bytes

Versions: 69

Compression:

Stored size: 620 Bytes

Contents

require 'socket'

module Celluloid
  # A TCPServer that runs as an actor
  class TCPServer
    include Celluloid::IO

    # Bind a TCP server to the given host and port
    def initialize(host, port)
      @server = ::TCPServer.new host, port
      run!
    end

    # Run the TCP server event loop
    def run
      while true
        wait_readable(@server)
        on_connect @server.accept
      end
    end

    # Terminate this server
    def terminate
      @server.close
      super
    end

    # Called whenever a new connection is opened
    def on_connect(connection)
      connection.close
    end
  end
end

Version data entries

69 entries across 69 versions & 2 rubygems

Version Path
engineyard-serverside-2.0.4 lib/vendor/celluloid/lib/celluloid/tcp_server.rb
engineyard-serverside-1.6.5 lib/vendor/celluloid/lib/celluloid/tcp_server.rb
engineyard-serverside-2.0.3 lib/vendor/celluloid/lib/celluloid/tcp_server.rb
engineyard-serverside-2.0.2 lib/vendor/celluloid/lib/celluloid/tcp_server.rb
engineyard-serverside-2.0.1 lib/vendor/celluloid/lib/celluloid/tcp_server.rb
engineyard-serverside-2.0.0 lib/vendor/celluloid/lib/celluloid/tcp_server.rb
engineyard-serverside-2.0.0.rc1 lib/vendor/celluloid/lib/celluloid/tcp_server.rb
engineyard-serverside-2.0.0.pre5 lib/vendor/celluloid/lib/celluloid/tcp_server.rb
engineyard-serverside-2.0.0.pre4 lib/vendor/celluloid/lib/celluloid/tcp_server.rb
engineyard-serverside-2.0.0.pre3 lib/vendor/celluloid/lib/celluloid/tcp_server.rb
engineyard-serverside-2.0.0.pre2 lib/vendor/celluloid/lib/celluloid/tcp_server.rb
engineyard-serverside-2.0.0.pre1 lib/vendor/celluloid/lib/celluloid/tcp_server.rb
engineyard-serverside-1.7.0.pre2 lib/vendor/celluloid/lib/celluloid/tcp_server.rb
engineyard-serverside-1.6.4 lib/vendor/celluloid/lib/celluloid/tcp_server.rb
engineyard-serverside-1.6.4.pre6 lib/vendor/celluloid/lib/celluloid/tcp_server.rb
engineyard-serverside-1.6.4.pre5 lib/vendor/celluloid/lib/celluloid/tcp_server.rb
engineyard-serverside-1.6.4.pre4 lib/vendor/celluloid/lib/celluloid/tcp_server.rb
engineyard-serverside-1.6.4.pre3 lib/vendor/celluloid/lib/celluloid/tcp_server.rb
engineyard-serverside-1.6.4.pre2 lib/vendor/celluloid/lib/celluloid/tcp_server.rb
engineyard-serverside-1.6.4.pre lib/vendor/celluloid/lib/celluloid/tcp_server.rb