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

Extra method to get ip. Using UDP datagram #54

Merged

Conversation

brunoais
Copy link
Contributor

@brunoais brunoais commented May 8, 2020

This method to try getting the local IP address seem to work correctly on linux and windows, even though for windows, the current method works just fine.

The way this code works depends on java's protected native void connect0(InetAddress address, int port) native C code java accessible through java.net.PlainDatagramSocketImpl.
The best way I was able to find to use such method is by making a datagram (UDP packet) and send it to nowhere reachable.

@brunoais brunoais changed the title Extra method to get ip Extra method to get ip. Using UDP datagram May 8, 2020
@kaklakariada
Copy link
Owner

Thank you for your pull request, looks good!

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 this pull request may close these issues.

2 participants