Search for machines on a port based LAN (network discovery) in android

I am looking for an Android application to scan every computer on the local network. 192.168.1.1-254 is looking for machines with an open port. I know a few manual ways to do this, but it will be a ton of code, and it will be required from time to time every time you need to search. Is there a quick way to specify a port and search for local devices with it?

Ex. The desktop has a web server on port 8888, you know the port, but not the IP address, attach the application to the port and quickly demonstrate the IP address.

+4
source share
1 answer

I assume that you know how to connect to the tcp server. If not, first go through

http://examples.javacodegeeks.com/android/core/socket-core/android-socket-example/

You can try to open several threads with each thread waiting to connect to a specific ip / port (along with some timeout value). If the thread throws an exception, it means that the connection was unsuccessful. Otherwise, add this ip address to the Open_Devices list.

0
source

Source: https://habr.com/ru/post/1486349/


All Articles