Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IP Address Return #80

Closed
francisyu1012 opened this issue Jan 10, 2024 · 3 comments
Closed

IP Address Return #80

francisyu1012 opened this issue Jan 10, 2024 · 3 comments
Assignees
Labels
question Further information is requested

Comments

@francisyu1012
Copy link

Describe the bug
When running with Android, I am able to see the the host as an IP address:

flutter (12628): Service resolved : {service.name: zz0138, service.type: _msb._tcp, service.port: 1505, service.attributes: {}, service.host: 192.168.4.126}

However in IOS and Windows, the response only gives me the hostname
flutter: Service resolved : {service.name: zz0077, service.type: _msb._tcp, service.port: 1505, service.attributes: {}, service.host: zz0077.local.}

Why the discrepancy and Is it possible to get the IP directly from this service?

To Reproduce
Steps to reproduce the behavior:
Built in IOS, Android and Windows using this code block

// If you want to listen to the discovery :
discovery.eventStream!.listen((event) { // `eventStream` is not null as the discovery instance is "ready" !
  if (event.type == BonsoirDiscoveryEventType.discoveryServiceFound) {
    print('Service found : ${event.service?.toJson()}');
    event.service!.resolve(discovery.serviceResolver); // Should be called when the user wants to connect to this service.
  } else if (event.type == BonsoirDiscoveryEventType.discoveryServiceResolved) {
    print('Service resolved : ${event.service?.toJson()}');
  } else if (event.type == BonsoirDiscoveryEventType.discoveryServiceLost) {
    print('Service lost : ${event.service?.toJson()}');
  }
});

// Start the discovery **after** listening to discovery events :
await discovery.start();

Expected behavior
A clear and concise description of what you expected to happen.

Desktop (please complete the following information):

  • OS: Windows 7

Smartphone (please complete the following information):

  • Device: Iphone 8
  • OS:IOS 16
    Smartphone (please complete the following information):
  • Device:Android
  • OS: Android 13
@francisyu1012 francisyu1012 added the bug Something isn't working label Jan 10, 2024
@Skyost
Copy link
Owner

Skyost commented Jan 10, 2024

Hey,

Why do you absolutely want the IP address instead of the hostname ? You're not using 140.82.121.4 to go on github.com, aren't you ?

@francisyu1012
Copy link
Author

It was more of a curiosity question regarding the discrepancy between scanning with Android vs. IOS and WIndows... Given the shift of using HTTPS which does not allow direct connection with IP's and .local, we will probably just use this to scan if the devices are in the same LAN. Thanks!

@Skyost Skyost added question Further information is requested and removed bug Something isn't working labels Jan 12, 2024
@Skyost
Copy link
Owner

Skyost commented Jan 12, 2024

It was more of a curiosity question regarding the discrepancy between scanning with Android vs. IOS and WIndows...

Understood. On Darwin platforms, Bonsoir rely on NWBrowser / DNSServiceResolve which only gives you the hostname. It should be possible to find the IP address using gethostbyname or getaddrinfo tho, as stated here.

@Skyost Skyost closed this as completed Jan 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants