mjansson / mdns

Public domain mDNS/DNS-SD library in C
The Unlicense
459 stars 120 forks source link

no internet at startup #74

Closed vinnitu closed 1 year ago

vinnitu commented 1 year ago

Hello!

I have such situation

My app as service can start without internet connection

but I want other client app can see it on my machine and other instance client on other machine see it after apperence internet on service machine )) do you understand me?

first question is - it is possible run service without internet? I need client and service see each other on the same machine in any case (with wifi or without) And I need other client from net can see apperance of service after wifi will connected

(error: Failed to open any client sockets)

vinnitu commented 1 year ago

My test on clear machine

With wi-fi

ubuntu@ubuntu:/tmp/mdns-main/build/bin$ ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: enp43s0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc fq_codel state DOWN group default qlen 1000
    link/ether 7c:8a:e1:8f:69:d2 brd ff:ff:ff:ff:ff:ff
3: wlp0s20f3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether f0:9e:4a:6d:0f:d3 brd ff:ff:ff:ff:ff:ff
    inet 192.168.75.39/24 brd 192.168.75.255 scope global dynamic noprefixroute wlp0s20f3
       valid_lft 3594sec preferred_lft 3594sec
    inet6 fe80::c4ad:25d2:b7eb:369a/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever

ubuntu@ubuntu:/tmp/mdns-main/build/bin$ ./mdns_example 
Local IPv4 address: 192.168.75.39
Opened 1 socket for DNS-SD
Sending DNS-SD discovery
Reading DNS-SD replies
Closed sockets

Without wi-fi

ubuntu@ubuntu:/tmp/mdns-main/build/bin$ ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: enp43s0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc fq_codel state DOWN group default qlen 1000
    link/ether 7c:8a:e1:8f:69:d2 brd ff:ff:ff:ff:ff:ff
3: wlp0s20f3: <BROADCAST,MULTICAST> mtu 1500 qdisc noqueue state DOWN group default qlen 1000
    link/ether f0:9e:4a:6d:0f:d3 brd ff:ff:ff:ff:ff:ff

ubuntu@ubuntu:/tmp/mdns-main/build/bin$ ./mdns_example 
Failed to open any client sockets
vinnitu commented 1 year ago

I do the same tests with avahi tools

Run service and browser with internet

image

without internet

image

vinnitu commented 1 year ago

with internet

image

without internet

image

image

mjansson commented 1 year ago

The mdns.c source is not intended as a proper service, it is just an example of how to use the API provided by the header only library in mdns.h

mjansson commented 1 year ago

If you want to have the same level of features when it comes to network interfaces and running a full fledged service like avahi you have to write plenty of more platform specific code yourself, it is not the goal of this library.