1Net::DBus::Binding::SerUvseerr(3C)ontributed Perl DocumeNnetta:t:iDoBnus::Binding::Server(3)
2
3
4
6 Net::DBus::Binding::Server - A server to accept incoming connections
7
9 Creating a new server and accepting client connections
10
11 use Net::DBus::Binding::Server;
12
13 my $server = Net::DBus::Binding::Server->new(address => "unix:path=/path/to/socket");
14
15 $server->connection_callback(\&new_connection);
16
17 sub new_connection {
18 my $connection = shift;
19
20 .. work with new connection...
21 }
22
23 Managing the server and new connections in an event loop
24
25 my $reactor = Net::DBus::Binding::Reactor->new();
26
27 $reactor->manage($server);
28 $reactor->run();
29
30 sub new_connection {
31 my $connection = shift;
32
33 $reactor->manage($connection);
34 }
35
37 A server for receiving connection from client programs. The methods
38 defined on this module have a close correspondance to the
39 dbus_server_XXX methods in the C API, so for further details on their
40 behaviour, the C API documentation may be of use.
41
43 my $server = Net::DBus::Binding::Server->new(address =>
44 "unix:path=/path/to/socket");
45 Creates a new server binding it to the socket specified by the
46 "address" parameter.
47
48 $status = $server->is_connected();
49 Returns zero if the server has been disconnected, otherwise a posi‐
50 tive value is returned.
51
52 $server->disconnect()
53 Closes this server to the remote host. This method is called auto‐
54 matically during garbage collection (ie in the DESTROY method) if
55 the programmer forgets to explicitly disconnect.
56
57 $server->set_watch_callbacks(\&add_watch, \&remove_watch, \&tog‐
58 gle_watch);
59 Register a set of callbacks for adding, removing & updating watches
60 in the application's event loop. Each parameter should be a code
61 reference, which on each invocation, will be supplied with two
62 parameters, the server object and the watch object. If you are
63 using a "Net::DBus::Binding::Reactor" object as the application
64 event loop, then the 'manage' method on that object will call this
65 on your behalf.
66
67 $server->set_timeout_callbacks(\&add_timeout, \&remove_timeout, \&tog‐
68 gle_timeout);
69 Register a set of callbacks for adding, removing & updating time‐
70 outs in the application's event loop. Each parameter should be a
71 code reference, which on each invocation, will be supplied with two
72 parameters, the server object and the timeout object. If you are
73 using a "Net::DBus::Binding::Reactor" object as the application
74 event loop, then the 'manage' method on that object will call this
75 on your behalf.
76
77 $server->set_connection_callback(\&handler)
78 Registers the handler to use for dealing with new incoming connec‐
79 tions from clients. The code reference will be invoked each time a
80 new client connects and supplied with a single parameter which is
81 the "Net::DBus::Binding::Connection" object representing the
82 client.
83
85 Net::DBus::Binding::Connection, Net::DBus::Binding::Bus,
86 Net::DBus::Binding::Message::Signal, Net::DBus::Binding::Mes‐
87 sage::MethodCall, Net::DBus::Binding::Message::MethodReturn,
88 Net::DBus::Binding::Message::Error
89
91 Daniel Berrange <dan@berrange.com>
92
94 Copyright 2004 by Daniel Berrange
95
96
97
98perl v5.8.8 2008-02-20 Net::DBus::Binding::Server(3)