.\" Automatically generated by Pod::Man 4.10 (Pod::Simple 3.35) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "AnyEvent::Handle::UDP 3pm" .TH AnyEvent::Handle::UDP 3pm "2019-02-18" "perl v5.28.1" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" AnyEvent::Handle::UDP \- client/server UDP handles for AnyEvent .SH "VERSION" .IX Header "VERSION" version 0.049 .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 7 \& my $echo_server = AnyEvent::Handle::UDP\->new( \& bind => [\*(Aq0.0.0.0\*(Aq, 4000], \& on_recv => sub { \& my ($data, $ae_handle, $client_addr) = @_; \& $ae_handle\->push_send($data, $client_addr); \& }, \& ); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This module is an abstraction around \s-1UDP\s0 sockets for use with AnyEvent. .SH "ATTRIBUTES" .IX Header "ATTRIBUTES" .SS "on_recv" .IX Subsection "on_recv" The callback for when a package arrives. It takes three arguments: the datagram, the handle and the address the datagram was received from. .SS "on_error" .IX Subsection "on_error" The callback for when an error occurs. It takes three arguments: the handle, a boolean indicating the error is fatal or not, and the error message. .SS "on_drain" .IX Subsection "on_drain" This sets the callback that is called when the send buffer becomes empty. The callback takes the handle as its only argument. .SS "autoflush" .IX Subsection "autoflush" Always attempt to send data to the operating system immediately, without waiting for the loop to indicate the filehandle is write-ready. .SS "receive_size" .IX Subsection "receive_size" The buffer size for the receiving in bytes. It defaults to 1500, which is slightly more than the \s-1MTA\s0 on ethernet. .SS "family" .IX Subsection "family" Sets the socket family. The default is \f(CW0\fR, which means either IPv4 or IPv6. The values \f(CW4\fR and \f(CW6\fR mean IPv4 and IPv6 respectively. .SS "fh" .IX Subsection "fh" The underlying filehandle. Note that this doesn't cooperate with the \f(CW\*(C`connect\*(C'\fR and \f(CW\*(C`bind\*(C'\fR parameters. .SS "reuse_addr" .IX Subsection "reuse_addr" If true will enable quick reuse of the bound address .SS "timeout" .IX Subsection "timeout" .SS "rtimeout" .IX Subsection "rtimeout" .SS "wtimeout" .IX Subsection "wtimeout" If non-zero, then these enables an \*(L"inactivity\*(R" timeout: whenever this many seconds pass without a successful read or write on the underlying file handle (or a call to \f(CW\*(C`timeout_reset\*(C'\fR), the on_timeout callback will be invoked (and if that one is missing, a non-fatal \s-1ETIMEDOUT\s0 error will be raised). .PP There are three variants of the timeouts that work independently of each other, for both read and write (triggered when nothing was read \s-1OR\s0 written), just read (triggered when nothing was read), and just write: timeout, rtimeout and wtimeout, with corresponding callbacks on_timeout, on_rtimeout and on_wtimeout, and reset functions timeout_reset, rtimeout_reset, and wtimeout_reset. .PP Note that timeout processing is active even when you do not have any outstanding read or write requests: If you plan to keep the connection idle then you should disable the timeout temporarily or ignore the timeout in the corresponding on_timeout callback, in which case AnyEvent::Handle will simply restart the timeout. .PP Calling \f(CW\*(C`clear_timeout\*(C'\fR (or setting it to zero, which does the same) disables the corresponding timeout. .SS "on_timeout" .IX Subsection "on_timeout" .SS "on_rtimeout" .IX Subsection "on_rtimeout" .SS "on_wtimeout" .IX Subsection "on_wtimeout" The callback that's called whenever the inactivity timeout passes. If you return from this callback, then the timeout will be reset as if some activity had happened, so this condition is not fatal in any way. .SH "METHODS" .IX Header "METHODS" .SS "new" .IX Subsection "new" Create a new \s-1UDP\s0 handle. As arguments it accepts any attribute, as well as these two: .IP "\(bu" 4 connect .Sp Set the address to which datagrams are sent by default, and the only address from which datagrams are received. It must be either a packed sockaddr struct or an arrayref containing a hostname and a portnumber. .IP "\(bu" 4 bind .Sp The address to bind the socket to. It must be either a packed sockaddr struct or an arrayref containing a hostname and a portnumber. .PP All except \f(CW\*(C`on_recv\*(C'\fR are optional, though using either \f(CW\*(C`connect\*(C'\fR or \f(CW\*(C`bind\*(C'\fR (or both) is strongly recommended unless you give it a connected/bound \f(CW\*(C`fh\*(C'\fR. .SS "bind_to($address)" .IX Subsection "bind_to($address)" Bind to the specified addres. Note that a bound socket may be rebound to another address. \f(CW$address\fR must be in the same form as the bind argument to new. .SS "connect_to($address)" .IX Subsection "connect_to($address)" Connect to the specified address. Note that a connected socket may be reconnected to another address. \f(CW$address\fR must be in the same form as the connect argument to new. .ie n .SS "push_send($message, $to = undef, $cv = AnyEvent::CondVar\->new)" .el .SS "push_send($message, \f(CW$to\fP = undef, \f(CW$cv\fP = AnyEvent::CondVar\->new)" .IX Subsection "push_send($message, $to = undef, $cv = AnyEvent::CondVar->new)" Try to send a message. If a socket is not connected a receptient address must also be given. If it is connected giving a receptient may not work as expected, depending on your platform. It returns \f(CW$cv\fR, which will become true when \f(CW$message\fR is sent. .SS "timeout_reset" .IX Subsection "timeout_reset" .SS "rtimeout_reset" .IX Subsection "rtimeout_reset" .SS "wtimeout_reset" .IX Subsection "wtimeout_reset" Reset the activity timeout, as if data was received or sent. .SS "sockname" .IX Subsection "sockname" Get the local address, per \f(CW\*(C`getsockname\*(C'\fR. .SS "peername" .IX Subsection "peername" Get the peer's address, per \f(CW\*(C`getpeername\*(C'\fR. .SS "destroy" .IX Subsection "destroy" Destroy the handle. .SH "BACKWARDS COMPATIBILITY" .IX Header "BACKWARDS COMPATIBILITY" This module is \fBnot\fR backwards compatible in any way with the defunct previous module of the same name by Jan Henning Thorsen. .SH "AUTHOR" .IX Header "AUTHOR" Leon Timmermans .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" This software is copyright (c) 2011 by Leon Timmermans. .PP This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.