How can I use sd_bus_* to connect over tcp to a remote dbus

Viewed 136

I have configured a remote target to expose a bus on a particular port. I have tested that I can connect and execute methods and receive the expected responses using both d-feet and dbus-send. For example:

dbus-send --bus='tcp:host=192.168.2.2,port=50000,family=ipv4' --print-reply --type=method_call --dest=:1.0 /net/connman/technology/ethernet net.connman.Technology.GetProperties

However, when I try something similar with the sd_bus_* api I am unsuccessful.

    int r;
    sd_bus *a;
    sd_bus_error error = SD_BUS_ERROR_NULL;

    r = sd_bus_new(&a);
    if (r < 0) {
        printf("error new\n");
        return 1;
    }

    const char *address = "tcp:host=192.168.2.2,port=50000,family=ipv4";
    r = sd_bus_set_address(a, address);
    if (r < 0) {
        printf("error set_address\n");
        return 1;
    }

    r = sd_bus_start(a);
    if (r < 0) {
        printf("error set_start\n");
        return 1;
    }

    r = sd_bus_call_method(a, ":1.0", "/net/connman/technology/ethernet", "net.connman.Technology", "GetProperties", &error, NULL);
    if (r < 0) {
        printf("error call %s\n", strerror(-r));
        return 1;
    }

I just get connection reset by peer. How can I solve this?

0 Answers
Related