NAME
    Mojo::Server::TCP - Generic TCP server

VERSION
    0.01

SYNOPSIS
      use Mojo::Server::TCP;
      my $echo = Mojo::Server::TCP->new(listen => ['tcp//*:9000']);

      $echo->on(read => sub {
        my($echo, $id, $chunk, $stream) = @_;
        $stream->write($chunk);
      });

      $echo->start;

DESCRIPTION
    Mojo::Server::TCP is a generic TCP server based on the logic of the
    Mojo::Server::Daemon.

EVENTS
  connect
      $self->on(close => sub { my($self, $id) = @_ });

    Emitted safely when a new client connects to the server.

  close
      $self->on(close => sub { my($self, $id) = @_ });

    Emitted safely if the stream gets closed.

  error
      $self->on(error => sub { my($self, $id, $str) = @_ });

  read
      $self->on(error => sub { my($self, $id, $chunk, $stream) = @_ });

    Emitted safely if new data arrives on the stream.

  timeout
      $self->on(timeout => sub { my($self, $stream) = @_ });

    Emitted safely if the stream has been inactive for too long and will get
    closed automatically.

ATTRIBUTES
  server_class
      $str = $daemon->server_class;
      $self = $self->server_class('Mojo::Server::Prefork');

    Used to set a custom server class. The default is Mojo::Server::Daemon.
    Check out Mojo::Server::Prefork if you want a faster server.

  listen
      $array_ref = $self->listen;
      $self = $self->listen(['tcp://localhost:3000']);

    List of one or more locations to listen on, defaults to "tcp://*:3000".

METHODS
  run
      $self = $self->run;

    Start accepting connections and run the server.

  start
      $self = $self->start;

    Start listening for connections. See also "run".

  stop
      $self = $self->stop;

    Stop the server.

AUTHOR
    Jan Henning Thorsen - "jhthorsen@cpan.org"

