Skip to content

No way to check, MDNSResponder::begin has been called or not #7214

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

Closed
BbIKTOP opened this issue Apr 14, 2020 · 3 comments · Fixed by #7219
Closed

No way to check, MDNSResponder::begin has been called or not #7214

BbIKTOP opened this issue Apr 14, 2020 · 3 comments · Fixed by #7219

Comments

@BbIKTOP
Copy link
Contributor

BbIKTOP commented Apr 14, 2020

There's currently no way to check, is MDNSResponder::begin already called. There shall be a method that returns true if begin has been called and false if not (or close/end has been called). There shall be a bool member field default to false, set to true if begin succeeded and back to false when close/end succedded, and some method like bool isBegan(void) to check it

@d-a-v
Copy link
Collaborator

d-a-v commented Apr 15, 2020

There are two solutions :

  • MDNSResponder::begin() returns a bool.
    When one needs mDNS, calling it the first time will tell if it has successfully started.
    One can retain the calling result in a personal bool variable to later remember if mDNS start method has already been successfully called.
  • Your question seems to suggest you'd like to call it several times and anytime.
    That is possible. First call will return true and all subsequent calls will return false. One can also ignore this return value.

Now f you read the code, you'll see that there is an internal variable holding that state. You are welcome to propose a pull request for a method bool ::isRunning().

@d-a-v d-a-v closed this as completed Apr 15, 2020
@BbIKTOP
Copy link
Contributor Author

BbIKTOP commented Apr 15, 2020

Evaluating begin’s return value wouldn’t help because it’s not possible to distinguish why was it failed - is there any real fatal error or is it already running. That’s why all kernel calls and standard lib calls either return error code or throw an exception clearly describing the reason.
Sorry, haven’t found this variable, could you give me a hint please?
I can create pull request, do i need to create separate requests for each issue?

@d-a-v
Copy link
Collaborator

d-a-v commented Apr 15, 2020

Here is the internal test.
It is likely that an additional public bool accessor with this test should be sufficient for your needs. It would not need more variables.

Separate pull request are always preferred when they are independent because they need to be commented accurately.

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

Successfully merging a pull request may close this issue.

2 participants