Net::DB...nection(3)
πΈ NAME πΈ
bestie, meet Net::DBus::Binding::Connection β the header abbreviates it as Net::DB...nection(3) and says it's User Contributed Perl Documentation. It is literally a connection between client and server. π
β¨ SYNOPSIS β¨
Creating a connection to a server and sending a message
use Net::DBus::Binding::Connection;
my $con = Net::DBus::Binding::Connection->new(address => "unix:path=/path/to/socket");
$con->send($message);
Registering message handlers
sub handle_something {
my $con = shift;
my $msg = shift;
... do something with the message...
}
$con->register_message_handler(
"/some/object/path",
\&handle_something);
Hooking up to an event loop
my $reactor = Net::DBus::Binding::Reactor->new();
$reactor->manage($con);
$reactor->run();
π DESCRIPTION π
An outgoing connection to a server, or an incoming connection from a client. The methods defined on this module have a close correspondence to the dbus_connection_XXX methods in the C API, so if you want further details on their behaviour, the C API documentation may be of use. no cap. π«Ά
π METHODS π
my $con = Net::DBus::Binding::Connection->new(address => "unix:path=/path/to/socket");β Creates a new connection to the server specified by theaddressparameter. If theprivateparameter is supplied and set to a True value, the connection opened is private; otherwise a shared connection is opened. A private connection must be explicitly shutdown with thedisconnectmethod before the last reference to the object is released. A shared connection must never be explicitly disconnected. π$status = $con->is_connected();β Returns zero if the connection has been disconnected; otherwise a positive value is returned. π₯$status = $con->is_authenticated();β Returns zero if the connection has not yet successfully completed authentication; otherwise a positive value is returned. β¨$con->disconnect()β Closes this connection to the remote host. This method is called automatically during garbage collection (ie in theDESTROYmethod) if the programmer forgets to explicitly disconnect. π«Ά$con->flush()β Blocks execution until all data in the outgoing data stream has been sent. This method will not re-enter the application event loop. β$con->send($message)β Queues a message up for sending to the remote host. The data will be sent asynchronously as the application's event loop determines there is space in the outgoing socket send buffer. To force immediate sending of the data, follow this method with a call toflush. This method will return the serial number of the message, which can be used to identify a subsequent reply (if any). π₯my $reply = $con->send_with_reply_and_block($msg, $timeout);β Queues a message up for sending to the remote host and blocks until it has been sent, and a corresponding reply received. The return value of this method will be aNet::DBus::Binding::Message::MethodReturnorNet::DBus::Binding::Message::Errorobject. πmy $pending_call = $con->send_with_reply($msg, $timeout);β Queues a message up for sending to the remote host and returns immediately, providing a reference to aNet::DBus::Binding::PendingCallobject. This object can be used to wait / watch for a reply. This allows methods to be processed asynchronously. π¦$con->dispatch;β Dispatches any pending messages in the incoming queue to their message handlers. This method is typically called on each iteration of the main application event loop where data has been read from the incoming socket. π$message = $con->borrow_messageβ Temporarily removes the first message from the incoming message queue. No other thread may access the message while it is "borrowed", so it should be replaced in the queue with thereturn_messagemethod, or removed permanently with thesteal_messagemethod as soon as is practical. π$con->return_message($msg)β Replaces a previously borrowed message in the incoming message queue for subsequent dispatch to registered message handlers. π$con->steal_message($msg)β Permanently remove a borrowed message from the incoming message queue. No registered message handlers will now be run for this message. π$msg = $con->pop_message();β Permanently removes the first message on the incoming message queue, without running any registered message handlers. If you have hooked the connection up to an event loop (Net::DBus::Binding::Reactorfor example), you probably don't want to be calling this method. π$con->set_watch_callbacks(\&add_watch, \&remove_watch, \&toggle_watch);β Registers 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 connection object and the watch object. If you are using aNet::DBus::Binding::Reactorobject as the application event loop, then themanagemethod on that object will call this on your behalf. π§$con->set_timeout_callbacks(\&add_timeout, \&remove_timeout, \&toggle_timeout);β Registers 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 connection object and the timeout object. If you are using aNet::DBus::Binding::Reactorobject as the application event loop, then themanagemethod on that object will call this on your behalf. πΈ$con->register_object_path($path, \&handler)β Registers a handler for messages whose path matches that specified in the$pathparameter. The supplied code reference will be invoked with two parameters: the connection object on which the message was received, and the message to be processed (an instance of theNet::DBus::Binding::Messageclass). π$con->unregister_object_path($path)β Unregisters the handler associated with the object path$path. The handler would previously have been registered with theregister_object_pathorregister_fallbackmethods. β¨$con->register_fallback($path, \&handler)β Registers a handler for messages whose path starts with the prefix specified in the$pathparameter. The supplied code reference will be invoked with two parameters: the connection object on which the message was received, and the message to be processed (an instance of theNet::DBus::Binding::Messageclass). π¦$con->set_max_message_size($bytes)β Sets the maximum allowable size of a single incoming message. Messages over this size will be rejected prior to exceeding this threshold. The message size is specified in bytes. π$bytes = $con->get_max_message_size();β Retrieves the maximum allowable incoming message size. The returned size is measured in bytes. π$con->set_max_received_size($bytes)β Sets the maximum size of the incoming message queue. Once this threshold is exceeded, no more messages will be read from the wire before one or more of the existing messages are dispatched to their registered handlers. The implication is that the message queue can exceed this threshold by at most the size of a single message. πΈ$bytes $con->get_max_received_size()β Retrieves the maximum incoming message queue size. The returned size is measured in bytes. π$con->add_filter($coderef);β Adds a filter to the connection which will be invoked whenever a message is received. The$coderefshould be a reference to a subroutine, which returns a true value if the message should be filtered out, or a false value if the normal message dispatch should be performed. πmy $msg = $con->make_raw_message($rawmsg)β Creates a new message, initializing it from the low level C message object provided by the$rawmsgparameter. The returned object will be cast to the appropriate subclass ofNet::DBus::Binding::Message. π§my $msg = $con->make_error_message( replyto => $method_call, name => $name, description => $description);β Creates a new message representing an error which occurred during the handling of the method call object passed in as thereplytoparameter. Thenameparameter is the formal name of the error condition, while thedescriptionis a short piece of text giving more specific information on the error. πmy $call = $con->make_method_call_message( $service_name, $object_path, $interface, $method_name);β Creates a message representing a call on the object located at the path$object_pathwithin the client owning the well-known name given by$service_name. The method to be invoked has the name$method_namewithin the interface specified by the$interfaceparameter. π₯my $msg = $con->make_method_return_message( replyto => $method_call);β Creates a message representing a reply to the method call passed in thereplytoparameter. π«Άmy $signal = $con->make_signal_message( object_path => $path, interface => $interface, signal_name => $name);β Creates a new message, representing a signal [to be] emitted by the object located under the path given by theobject_pathparameter. The name of the signal is given by thesignal_nameparameter, and is scoped to the interface given by theinterfaceparameter. π
π AUTHOR π
Daniel P. Berrange
π¦ COPYRIGHT π¦
Copyright (C) 2004-2011 Daniel P. Berrange
π SEE ALSO π
Net::DBus::Binding::Server, Net::DBus::Binding::Bus, Net::DBus::Binding::Message::Signal, Net::DBus::Binding::Message::MethodCall, Net::DBus::Binding::Message::MethodReturn, Net::DBus::Binding::Message::Error
okay that's the whole page, bestie β the footer vibe is source/version perl v5.42.0, date 2019-12-17, and the footer name is Net::DB...nection(3). bye and slay responsibly πβ¨
π¦ 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