{"id":30211312,"url":"https://github.com/mons/anyevent-socket-more","last_synced_at":"2025-08-13T20:36:03.203Z","repository":{"id":136416508,"uuid":"1609858","full_name":"Mons/AnyEvent-Socket-More","owner":"Mons","description":"AnyEvent::Socket. Extended","archived":false,"fork":false,"pushed_at":"2012-10-18T15:12:01.000Z","size":138,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2023-03-10T20:33:08.153Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://search.cpan.org/dist/AnyEvent-Socket-More","language":"Perl","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Mons.png","metadata":{"files":{"readme":"README","changelog":"Changes","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2011-04-13T15:21:08.000Z","updated_at":"2023-03-10T20:46:17.563Z","dependencies_parsed_at":"2023-03-10T20:46:17.511Z","dependency_job_id":null,"html_url":"https://github.com/Mons/AnyEvent-Socket-More","commit_stats":null,"previous_names":[],"tags_count":null,"template":null,"template_full_name":null,"purl":"pkg:github/Mons/AnyEvent-Socket-More","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mons%2FAnyEvent-Socket-More","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mons%2FAnyEvent-Socket-More/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mons%2FAnyEvent-Socket-More/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mons%2FAnyEvent-Socket-More/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Mons","download_url":"https://codeload.github.com/Mons/AnyEvent-Socket-More/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mons%2FAnyEvent-Socket-More/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270305890,"owners_count":24562113,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-13T02:00:09.904Z","response_time":66,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-08-13T20:34:30.751Z","updated_at":"2025-08-13T20:36:03.134Z","avatar_url":"https://github.com/Mons.png","language":"Perl","funding_links":[],"categories":[],"sub_categories":[],"readme":"NAME\n    AnyEvent::Socket::More - AnyEvent::Socket. Extended\n\nSYNOPSIS\n        package Sample;\n        use AnyEvent::Socket::More;\n\n        my ($sock,$host,$port) = tcp_listen localhost =\u003e 80;\n\n        # fork, fork ...\n\n        tcp_accept($sock, sub {\n        ...\n        });\n\nDESCRIPTION\n    This module contain 2 additional functions: \"tcp_listen\" (that creates\n    listen socket) and \"tcp_accept\" (that accepts connections on listen\n    socket) They both are the same as \"tcp_server\" in AnyEvent::Socket, but\n    splitted in 2 parts.\n\n    $sock, [$host, $port] = tcp_listen $host, $service[, $prepare_cb]\n        Create and bind a stream socket to the given host, and port, set the\n        SO_REUSEADDR flag (if applicable) and call \"listen\". Unlike the name\n        implies, this function can also bind on UNIX domain sockets.\n\n        For internet sockets, $host must be an IPv4 or IPv6 address (or\n        \"undef\", in which case it binds either to 0 or to \"::\", depending on\n        whether IPv4 or IPv6 is the preferred protocol, and maybe to both in\n        future versions, as applicable).\n\n        To bind to the IPv4 wildcard address, use 0, to bind to the IPv6\n        wildcard address, use \"::\".\n\n        The port is specified by $service, which must be either a service\n        name or a numeric port number (or 0 or \"undef\", in which case an\n        ephemeral port will be used).\n\n        For UNIX domain sockets, $host must be \"unix/\" and $service must be\n        the absolute pathname of the socket. This function will try to\n        \"unlink\" the socket before it tries to bind to it. See SECURITY\n        CONSIDERATIONS, below.\n\n        Croaks on any errors it can detect before the listen.\n\n        If you need more control over the listening socket, you can provide\n        a \"$prepare_cb-\u003e($fh, $host, $port)\", which is called just before\n        the \"listen ()\" call, with the listen file handle as first argument,\n        and IP address and port number of the local socket endpoint as\n        second and third arguments.\n\n        It should return the length of the listen queue (or 0 for the\n        default (128)).\n\n        Note to IPv6 users: RFC-compliant behaviour for IPv6 sockets\n        listening on \"::\" is to bind to both IPv6 and IPv4 addresses by\n        default on dual-stack hosts. Unfortunately, only GNU/Linux seems to\n        implement this properly, so if you want both IPv4 and IPv6 listening\n        sockets you should create the IPv6 socket first and then attempt to\n        bind on the IPv4 socket, but ignore any \"EADDRINUSE\" errors.\n\n        Example: bind on some TCP port on the local machine and tell each\n        client to go away.\n\n           my $sock = tcp_listen undef, undef, sub {\n          my ($fh, $thishost, $thisport) = @_;\n          warn \"bound to $thishost, port $thisport\\n\";\n          return 0;\n           };\n\n    $guard = tcp_accept $sock, $accept_cb;\n        For each new connection that could be \"accept\"ed, call the\n        \"$accept_cb-\u003e($fh, $host, $port)\" with the file handle (in\n        non-blocking mode) as first, and the peer host and port as second\n        and third arguments (see \"tcp_connect\" for details).\n\n        If called in non-void context, then this function returns a guard\n        object whose lifetime it tied to the TCP server: If the object gets\n        destroyed, the server will be stopped (but existing accepted\n        connections will not be affected).\n\n        Example: Accept connections on listen socket\n\n           tcp_accept $sock, sub {\n          my ($fh, $host, $port) = @_;\n\n          syswrite $fh, \"The internet is full, $host:$port. Go away!\\015\\012\";\n           };\n\n    $sock, [$host, $port] = udp_listen $host, $service[, $prepare_cb]\n        Create and bind an UDP datagram socket to the given host, and port,\n        set the SO_REUSEADDR flag (if applicable). Unlike the name implies,\n        this function can also bind on UNIX domain sockets.\n\n        Example:\n\n        my $fh = udp_listen( '127.0.0.1', 7777 );\n\n    $guard = udp_accept $sock [, $buffersize = 65536 ],\n    $readcb-\u003e(\\$message);\n        Waits for messages on udp socket, reads them and invoke callback\n        with a reference to message buffer\n\n        Example:\n\n        my $fh = udp_listen( '127.0.0.1', 7777 );\n        # fork some times\n        if ($child) {\n            udp_accept $fh, 4096, sub {\n            my $rmsg = shift;\n            say \"Received message: \".$$rmsg;\n            }\n        }\n\n        Also simple AE::io watcher may be used insted\n\n        my $w = AE::io $fh, 0, sub {\n            while(recv $fh, $buffersize, $flags) {\n            # ...\n            }\n        }\n\n    $guard = udp_server $host, $service [, $buffersize = 65536,\n    $prepace_cb-\u003e($fh) ], $readcb-\u003e(\\$message);\n        Simple concatenation of udp_listen + udp_accept;\n\n        Example:\n\n        udp_server 'localhost', 1234, 4096, sub {\n            my $rmsg = shift;\n            say \"Received message: \".$$rmsg;\n        };\n\n    $guard = udp_connect $host, $service, $prepare_cb, $callback\n        Call equivalent to tcp_connect but with SOCK_DGRAM and IPPROTO_UDP\n\n        Example:\n\n        udp_connect localhost =\u003e 1234, sub {\n            my $fh = shift;\n            my $io;$io = AE::io $fh, 1, sub {\n            send( $fh, \"Message\", 0 );\n            undef $io;\n            };\n        };\n\nAUTHOR\n    Mons Anderson, \"\u003cmons@cpan.org\u003e\"\n\n    Based on Marc Lehmann's AnyEvent::Socket\n\nLICENSE\n    This program is free software; you can redistribute it and/or modify it\n    under the terms of either: the GNU General Public License as published\n    by the Free Software Foundation; or the Artistic License.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmons%2Fanyevent-socket-more","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmons%2Fanyevent-socket-more","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmons%2Fanyevent-socket-more/lists"}