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

call_method does not function correctly when a service has both UDP and TCP ports #33

Open
dayangshanbaoye opened this issue Dec 17, 2024 · 1 comment

Comments

@dayangshanbaoye
Copy link

dayangshanbaoye commented Dec 17, 2024

If a service is provided on both UDP and TCP port, this info can not be handled correctly in self._offered_services. So I think we need to add a condition to make sure the provided service has the same protocol with the Client Service Instance, either TCP or UDP.

Before

# At this point the service should be found since an exception would have been raised before
        for s in self._offered_services:
            if s.service_id == self._service.id and s.instance_id == self._instance_id:
                dst_address = str(s.endpoint[0])
                dst_port = s.endpoint[1]
                break

After

for s in self._offered_services:
            if (
                s.service_id == self._service.id 
                and s.instance_id == self._instance_id 
                and s.protocol == self._protocol
            ):
                dst_address = str(s.endpoint[0])
                dst_port = s.endpoint[1]
                break

By the way, the snippets in the call_method, which specifies the UDP condition seems to be duplicated.

# In case of UDP, just send out the datagram and wait for the response
            # At this point the service should be found since an exception would have been raised before
            for s in self._offered_services:
                if (
                    s.service_id == self._service.id
                    and s.instance_id == self._instance_id
                ):
                    dst_address = str(s.endpoint[0])
                    dst_port = s.endpoint[1]
                    break
@dayangshanbaoye
Copy link
Author

0: IPv4 Endpoint Option (172.16.64.64:53000 (UDP))
1: IPv4 Endpoint Option (172.16.64.64:53001 (TCP))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant