Giter VIP home page Giter VIP logo

anyevent-tcp-server's Introduction

AnyEvent::TCP::Server

NAME

AnyEvent::TCP::Server

DESCRITPION

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

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();

anyevent-tcp-server's People

Contributors

justnoxx avatar

Watchers

 avatar  avatar

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.