GithubHelp home page GithubHelp logo

anyevent-tcp-server's Introduction

AnyEvent::TCP::Server

NAME

AnyEvent::TCP::Server

WARNINGS

I am not sure that it will work correct on FreeBSD 9 and Windows, but sure, that it will work on linux.

DESCRITPION

High perfomance pre-forking full-asynchronous tcp server. One restriction: you can't get client info inside process_request subroutine.

Yeah. this thing is really blazing fast. You can try it by benchmarking hello-world http server.

What's next

I working hard on this thing and I'll create PSGI server. And one more. After 1.0 version release of this software, I'll make this code as deprecated. Why? There is another thing with same functional, but faster, is under construction. Api will be complete compatible.

METHODS

new creates AE::TCP::Server object. Params:

  • workers - workers count
  • pid - path to pid file
  • daemonize - daemonize or not
  • debug - debug mode
  • user - user for setuid
  • group - group for setgid
  • procname - name of process for ps
  • port - port to listen. Unix sockets not supported right now
  • process_request - subroutine ref for processing requests

run runs connection manager and blocks.

SYNOPSIS

Little example, how to use it:

use AnyEvent::TCP::Server;
my $ae_srvr = AnyEvent::TCP::Server->new(
    # will daemonize
    daemonize           =>  1,

    # path to pid file, which used for master process pid
    # pid               =>  '/path/to/pid/file',

    # enables advanced debug
    debug               =>  1,

    # process name, used for ps
    procname            =>  'my_cool_example',

    # port to listen
    port                =>  44444,

    # on connect subroutine, if returns false - connection will terminated.
    check_on_connect    =>  sub {
        my ($fh, $host, $port) = @_;
        return 1;
    },

    # main subroutine, it used by workers for request processing.
    process_request     =>  sub {
        my ($worker_object, $fh, undef) = @_;
        syswrite $fh, "[$$]: Hello!";
        close $fh;
    },
);

# run server
$ae_srvr->run();

AUTHORS

Dmitriy @justnoxx Shamatrin

Michael @michaelshulichenko Shulichenko

Denys @shmakins Fisher

anyevent-tcp-server's People

Contributors

justnoxx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

anyevent-tcp-server's Issues

CPAN

Hi!

What about CPAN distribution? :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.