GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Danga::Socket::Callback(3) User Contributed Perl Documentation Danga::Socket::Callback(3)

Danga::Socket::Callback - Use Danga::Socket From Callbacks

  my $danga = Danga::Socket::Callback->new(
    handle         => $socket,
    context        => { ... },
    on_read_ready  => sub { ... },
    on_write_ready => sub { ... },
    on_error       => sub { ... },
    on_signal_hup  => sub { ... },
  );

  Danga::Socket->EventLoop();

Love the fact that Perlbal, Mogilefs, and friends all run fast because of Danga::Socket, but despise it because you need to subclass it every time? Well, here's a module for all you lazy people.

Danga::Socket::Callback is a thin wrapper arond Danga::Socket that allows you to set callbacks to be called at various events. This allows you to define multiple Danga::Socket-based sockets without defining multiple classes:

  my $first = Danga::Socket::Callback->new(
    hadle => $sock1,
    on_read_ready => \&sub1
  );

  my $second = Danga::Socket::Callback->new(
    hadle => $sock2,
    on_read_ready => \&sub2
  );

  Danga::Socket->EventLoop();

Creates a new instance of Danga::Socket::Callback. Takes the following parameters:
handle
The socket/handle to read from.
context
Arbitrary data to be shared between your app and Danga::Socket::Callback.
on_read_ready
Specify the code reference to be fired when the socket is ready to be read
on_write_ready
Specify the code reference to be fired when the socket is ready to be written
on_error
Specify te code reference to be fired when there was an error
on_signal_hup
Specify the code reference to be fired when a HUP signal is received.

Implements each method available from Danga::Socket. If the corresponding callbacks are available, then calls the callback. Each callback receives the Danga::Socket::Callback object.

For event_write, if no callback is available, then the default event_write method from Danga::Socket is called.

Possibly. I don't claim to use 100% of Danga::Socket. If you find any, please report them (preferrably with a failing test case)

Copyright (c) Daisuke Maki <daisuke@endeworks.jp> All rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

See http://www.perl.com/perl/misc/Artistic.html

2022-04-07 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.