Net::DB...:Server(3)
β¨ NAME β¨
Net::DBus::Binding::Server β a server to accept incoming connections π
okay so this is the Net::DBus::Binding::Server(3) page from the User Contributed Perl Documentation (the header lowkey abbreviates it as Net::DB...:Server(3), but bestie we're using the full name). It's giving "accept incoming connections" main-character energy, no cap. β¨
πΈ SYNOPSIS πΈ
Creating a new server and accepting client connections β starter pack, slay:
use Net::DBus::Binding::Server;
my $server = Net::DBus::Binding::Server->new(address => "unix:path=/path/to/socket");
$server->connection_callback(\&new_connection);
sub new_connection {
my $connection = shift;
.. work with new connection...
}
iykyk: the synopsis literally says $server->connection_callback(\&new_connection);, and the METHODS section below says set_connection_callback β both are exactly as written in the original, so I'm not editing the plot. π
Managing the server and new connections in an event loop β now we're getting the reactor involved:
my $reactor = Net::DBus::Binding::Reactor->new();
$reactor->manage($server);
$reactor->run();
sub new_connection {
my $connection = shift;
$reactor->manage($connection);
}
π¦ DESCRIPTION π¦
Bestie, this is a server for receiving connection from client programs. The methods defined on this module have a close correspondence to the dbus_server_XXX methods in the C API, so for further details on their behaviour, the C API documentation may be of use. periodt. π
π METHODS π
okay so here's the method rundown, and yes every signature is staying exactly as written. No renaming, no merging, no "fixing" the docs. we don't do that here. π
my $server = Net::DBus::Binding::Server->new(address => "unix:path=/path/to/socket");β Creates a new server binding it to the socket specified by theaddressparameter. Slay, you made a server. π«Ά$status = $server->is_connected();β Returns zero if the server has been disconnected, otherwise a positive value is returned. So zero = disconnected, positive = connected-ish. The docs say positive, bestie. β$server->disconnect();β Closes this server to the remote host. This method is called automatically during garbage collection (ie in theDESTROYmethod) if the programmer forgets to explicitly disconnect. So yes, cleanup is automatic, but don't make forgetting the whole plan. π$server->set_watch_callbacks(\&add_watch, \&remove_watch, \&toggle_watch);β Register a set of callbacks for adding, removing & updating watches in the application's event loop. Each parameter should be a code reference, which on each invocation, will be supplied with two parameters, the server object and the watch object. If you are using aNet::DBus::Binding::Reactorobject as the application event loop, then the'manage'method on that object will call this on your behalf. The'manage'is in single quotes in the source, so I'm keeping it. π$server->set_timeout_callbacks(\&add_timeout, \&remove_timeout, \&toggle_timeout);β Register a set of callbacks for adding, removing & updating timeouts in the application's event loop. Each parameter should be a code reference, which on each invocation, will be supplied with two parameters, the server object and the timeout object. If you are using aNet::DBus::Binding::Reactorobject as the application event loop, then the'manage'method on that object will call this on your behalf. Same deal, but for timeouts. β°$server->set_connection_callback(\&handler)β Registers the handler to use for dealing with new incoming connections from clients. The code reference will be invoked each time a new client connects and supplied with a single parameter which is theNet::DBus::Binding::Connectionobject representing the client. This is the main-character callback for fresh clients. π
π AUTHOR π
Daniel P. Berrange. That's the author, bestie. π«Ά
π COPYRIGHT π
Copyright (C) 2004-2011 Daniel P. Berrange. Keep it exact, keep it iconic. π
π SEE ALSO π
okay so go check out these modules too, they're all listed in the original and I'm listing every single one with no skips:
Net::DBus::Binding::ConnectionNet::DBus::Binding::BusNet::DBus::Binding::Message::SignalNet::DBus::Binding::Message::MethodCallNet::DBus::Binding::Message::MethodReturnNet::DBus::Binding::Message::Error
and that's the tea β β the footer says perl v5.42.0, dated 2019-12-17, and the title down there is still Net::DB...:Server(3). mwah πβ¨
π¦ where this page comes from
- opensuse-leap 16.0: perl-Net-DBus 1.2.0-160000.2.2 Β· GPL-2.0-or-later
- opensuse-leap 16.0: perl-Net-DBus 1.2.0-160000.2.2 Β· GPL-2.0-or-later
- opensuse-leap 16.0: perl-Net-DBus 1.2.0-160000.2.2 Β· GPL-2.0-or-later
- opensuse-leap 16.0: perl-Net-DBus 1.2.0-160000.2.2 Β· GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms