How to get tcp listen port

Thiago Macieira thiago at
Mon Feb 25 13:11:49 PST 2008

Joshua Swink wrote:
>How can I determine what TCP port dbus-daemon is listening on?
>I have set my system dbus-daemon to listen on a system-selected port,
>which it does. I can determine the port as root (e.g., sudo netstat
>-ptl). But how can I get the port 1) with user privileges, and 2)
>without rebooting?
>My best current guess would be to modify the init script,
>/etc/init.d/dbus, to use the "--print-address" option and to save the
>output somewhere like /var/run/dbus/addresses. I was just wondering if
>there is a better way.

Save it in an environment variable (DBUS_SESSION_BUS_ADDRESS). That's how 
client applications find the bus.

The same applies to the system bus (DBUS_SYSTEM_BUS_ADDRESS).
  Thiago Macieira  -  thiago (AT) - thiago (AT)
    PGP/GPG: 0x6EF45358; fingerprint:
    E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
Url : 

More information about the dbus mailing list