D-Bus with Perl Emmanuel Rodriguez Vienna 2008. 2 What is D-Bus? ● A message bus system (IPC) – Influenced by KDE's DCOP – Language independent (C/C++,

Slides:



Advertisements
Similar presentations
Message Passing Vs Distributed Objects
Advertisements

Remote Method Invocation (RMI) Mixing RMI and sockets
Socket Programming Application Programming Interface.
Copyright © 2001 Qusay H. Mahmoud RMI – Remote Method Invocation Introduction What is RMI? RMI System Architecture How does RMI work? Distributed Garbage.
Implementing Remote Procedure Calls Andrew Birrell and Bruce Nelson Presented by Kai Cong.
Remote Method Invocation Chin-Chih Chang. Java Remote Object Invocation In Java, the object is serialized before being passed as a parameter to an RMI.
Socket Programming.
CS490T Advanced Tablet Platform Applications Network Programming Evolution.
Netprog RPC Overview1 Distributed Program Design n Communication-Oriented Design –Design protocol first. –Build programs that adhere to the protocol.
Lesson 3 Remote Method Invocation (RMI) Mixing RMI and sockets Rethinking out tic-tac-toe game.
Chapter 26 Client Server Interaction Communication across a computer network requires a pair of application programs to cooperate. One application on one.
© 2010 UEI, Inc. All Rights Reserved UEIPAC HMI.
Introduction to Ice Copyright © ZeroC, Inc. Ice Programming with Java 1. Introduction to Ice.
1 Chapter Client-Server Interaction. 2 Functionality  Transport layer and layers below  Basic communication  Reliability  Application layer.
Server Sockets: A server socket listens on a given port Many different clients may be connecting to that port Ideally, you would like a separate file descriptor.
1 CSC111H Client-Server: An Introduction Dennis Burford
1 Cisco Unified Application Environment Developers Conference 2008© 2008 Cisco Systems, Inc. All rights reserved.Cisco Public Introduction to Etch Scott.
Windows Network Programming ms-help://MS.MSDNQTR.2004JAN.1033/winsock/winsock/windows_sockets_start_page_2.htm 井民全.
CS 158A1 1.4 Implementing Network Software Phenomenal success of the Internet: – Computer # connected doubled every year since 1981, now approaching 200.
Distributed Computing A Programmer’s Perspective.
X-WindowsP.K.K.Thambi The X Window System Module 5.
1 Developing Application in Distributed Computing Environment (DCE)
The Client-Server Model And the Socket API. Client-Server (1) The datagram service does not require cooperation between the peer applications but such.
GLOBAL EDGE SOFTWERE LTD1 R EMOTE F ILE S HARING - Ardhanareesh Aradhyamath.
Lecture 4 Mechanisms & Kernel for NOSs. Mechanisms for Network Operating Systems  Network operating systems provide three basic mechanisms that support.
Netprog: Client/Server Issues1 Issues in Client/Server Programming Refs: Chapter 27.
1 Network Communications A Brief Introduction. 2 Network Communications.
Sockets A popular API for client-server interaction.
CORBA Antonio Vasquez, John Shelton, Nidia, Ruben.
OLPC and Mono The Sugar Datastore
D-Bus and Friends: Making Linux “Just Work” on the Desktop John (J5) Palmieri Desktop Engineer
1 Issues in Client/Server Refs: Chapter 27 Case Studies RFCs.
Object-Orientated Analysis, Design and Programming
JavaIOC Overview and Update
Boots Cassel Villanova University
Sockets and Beginning Network Programming
Chapter 2: Operating-System Structures
Prof. Leonardo Mostarda University of Camerino
Chapter 5 Remote Procedure Call
What is RMI? Remote Method Invocation
AppArmor Update 2014 Linux Security Summit
Debugging DBus Ted Gould Device Sprint Oct 2014
Client-Server Interaction
Chapter 2: Operating-System Structures
Interacting With Protocol Software
CSCI 315 Operating Systems Design
CMSC621: Advanced Operating Systems Advanced Operating Systems
Chapter 2: The Linux System Part 2
SLAC USA Marty Kraimer and Matej Sekoranja
Chapter 2: System Structures
Interprocess Communication
Lecture 4: RPC Remote Procedure Call Coulouris et al: Chapter 5
CIS Distributed and Parallel Architectures
Multiple Processor Systems
Chapter 40 Remote Method Invocation
Lecture 4: RPC Remote Procedure Call CDK: Chapter 5
Distributed Program Design
Issues in Client/Server Programming
CSE 451: Operating Systems Autumn 2009 Module 21 Remote Procedure Call (RPC) Ed Lazowska Allen Center
Chapter 46 Remote Method Invocation
Multiple Processor and Distributed Systems
Chapter 46 Remote Method Invocation
Chapter 2: Operating-System Structures
Presented By: Kwangsung Oh
Sockets Programming Socket to me!.
Sockets Programming Socket to me!.
CSE 451: Operating Systems Autumn 2010 Module 21 Remote Procedure Call (RPC) Ed Lazowska Allen Center
CSE 451: Operating Systems Messaging and Remote Procedure Call (RPC)
Exceptions and networking
Presentation transcript:

D-Bus with Perl Emmanuel Rodriguez Vienna 2008

2 What is D-Bus? ● A message bus system (IPC) – Influenced by KDE's DCOP – Language independent (C/C++, Python, Perl, etc) ● Simple way for applications to talk to one another ● Provides a system and session bus ● Used in Gnome, KDE, maemo, OLPC, etc

3 Yet another IPC? ● One-to-one, peer-to-peer or client-server ● Low-latency – avoids round trips and can be asynchronous ● Low-overhead – protocol is binary and can be in machine's endianness ● Fully introspectable ● Multiple transports (Unix sockets, TCP/IP, etc) ● Supports authentication

4 Implementation ● Low level library (libdbus) ● Message bus daemon (dbus-daemon) – System bus for kernel events and main daemons – Session bus for applications and desktop session ● High level bindings – Glib (C) – Perl (Glib) – Python – Java (Glib or pure java)

5 Communication between ● Desktop applications in the same session – Programs – Session Kernel System bus Network Manager AvahiHal Desktop Blueto oth dhcp Desktop Session bus Setti ngs Rhythmb ox Power Management Pidgi n Skyp e ● Desktop session and the OS – Kernel – System daemons

6 D-Bus objects ● Services (applications) are found by name – org.gnome.Rhythmbox ● A service can export multiple objects – /org/gnome/Rhythmbox/Player – /org/gnome/Rhythmbox/Shell ● Each object implements at least one interface – org.gnome.Rhythmbox.Player – org.freedesktop.DBus.Introspectable

7 Example - Client ● Connect to Pidgin and list all the accounts use Net::DBus; # Connect to Pidgin through D-Bus my $pidgin = Net::DBus->session ->get_service('im.pidgin.purple.PurpleService') ->get_object('/im/pidgin/purple/PurpleObject') ; # Loop through all accounts available in Pidgin my $accounts = $pidgin->PurpleAccountsGetAll(); foreach my $account $accounts }) { # For each account get the protocol and the name my $protocol = $pidgin->PurpleAccountGetProtocolName($account); my $name = $pidgin->PurpleAccountGetUsername($account); printf "%-4s %s\n", $protocol, $name; }

8 Example – Service (1) ● D-Bus object that can be shared package DBus::Greeting; # Invoke the exporter utility and specify the default interface name use Net::DBus::Exporter 'org.example.Greeting'; # Become a D-Bus object use base 'Net::DBus::Object'; sub new { my ($class, $service) # Call the parent's constructor with a service and a path for this instance my $self = $class->SUPER::new($service, '/org/example/Greeting'); bless $self, $class; } # Register a method named “Hello” that takes a string as argument # and returns a string dbus_method('Hello', ['string'], ['string']); sub Hello { my $self = shift; my ($name) return "Hello $name"; }

9 Example – Service (2) ● Share a D-Bus object with the world use Net::DBus; use Net::DBus::Reactor; # Our object (previous slide) use DBus::Greeting; # Request a service name for the object to be shared my $service = Net::DBus->session->export_service('org.example.Greeting'); # Export an object to our service my $object = DBus::Greeting->new($service); # Start a main loop and wait for incoming requests Net::DBus::Reactor->main->run();

10 Exporting services ● The bus knows all services exported ● It can also start services on demand if a service is not running yet ● Simply create a.service file in /usr/share/dbus- 1/services/ [D-BUS Service] Name=org.example.FileWatcher Exec=/tmp/dbus/dbus-file-watcher.pl

11 Introspectable dbus-send --session --dest=org.example.FileWatcher –print-reply /org/example/FileWatcher org.freedesktop.DBus.Introspectable.Introspect...

12 Typical usage ● Application gets a connection to a bus – Each connection gets a unique bus name (:1.12) ● There's no distinction between client/service – A service usually: ● Exports a service name (org.freedesktop.Hal) ● Shares at least one object (/org/freedesktop/Hal) ● Responds to method calls and can emits signals – A client usually: ● Gets an instance to a known object (shared by a service) ● Invokes methods or connects to signals

13 Messages Types ● Method Calls (client -> service) ● Responses (service -> client) – No reply – Value(s) – Errors (exceptions) ● Signals (service -> clients)

14 Data Types ● Basic types – invalid, byte, boolean, int, double, string ● Containers – Struct (just like in C) – Array – Variant (Generic scalar value) – Dictionnary (Hashtable key must be a basic type)

15 End Questions?