Jump to content
limelect

Discover all LAN network with a PC

Recommended Posts

This project is an Android for network discovery 

https://github.com/rorist/android-network-discovery

It has all devices on the wifi network

It seems I do not succeed to duplicate this in Delphi 10.2 FOR A PC

Any function will help. Plz EXACT duplicate.

Thanks

THIS IS FOR MY PC PROGRAM

P.S it has my phone my computer and more

device-2020-12-20-104421.png

Edited by limelect

Share this post


Link to post
2 hours ago, limelect said:

It seems I do not succeed to duplicate this in Delphi 10.2

What have you tried? Does none of it succeed, or only certain parts?

Share this post


Link to post

I can put a lot of functions/procedure from the net it will be crazy

more than 10 from google search none gave me a LIST 

with associated software, it will be a few pages. 

 

Edited by limelect

Share this post


Link to post
9 hours ago, limelect said:

Associated to button 1. So many it is usless

Either you posted the wrong source (a VCL app), or your question needs editing. It appears you wanted to replicate some Java code in Delphi.

Share this post


Link to post

Why not just use the Nirsoft Wireless Network Watcher tool, it's not really wireless related, just lists details of all LAN IP addresses if finds similarly to your earlier screen shot.  It runs 24/7 on my network, it keeps a database of last contact times and names, for phones and NEST devices that only connect periodically. 

 

It continually pings all addresses on the LAN, then does reverse DNS lookups, and gets MAC addresses from the Windows ARP table. (probably). 

 

Angus

 

Share this post


Link to post

@Angus Robertson Let me explain what I want to achieve 

I would like to press on an IP I receive, In a Delphi program, from my phone and

use it in Delphi PC software.

That it.

I know I can see my IP on my phone, which changes, or, which I do now,

use "network discovery".

I am trying to add a function/procedure which will

be part of a software.

P.S maybe I did not write the right words on Google search? 

 

Edited by limelect

Share this post


Link to post

Sorry, still not clear.  What has a phone got to do with a Windows Delphi application.  And what does 'press an IP' mean,  What is your business requirement?

 

Angus

 

 

Share this post


Link to post

@Angus Robertson Phone has a lot to do with a PC

Communicating to a phone from the PC

And if the above Android application dose I want too

It discovers MY PC MY PHONE and more on 10.....

why can't I do it with Delphi?

 

 

Edited by limelect

Share this post


Link to post

So you are trying to find the dynamic IP address of a specific device on your LAN? 

 

The easiest solution is to avoid dynamic addresses and arrange the DHCP server to allocate a reserved IP address to the phone, that is what I do, although that only works for IPv4. 

 

Otherwise you can use the ARP table I mentioned previously to find the LAN IPs and MACs your PC has connected to, but you may need to also ping the IP you expect before anything shows in ARP. the  Internet Protocol Helper Component does ARP, ping is available from many places, including ICS. 

 

Angus

 

 

Share this post


Link to post

@Angus Rober thanks I will check that info

It seems I have what I need on the ARP. 

But I need the name of the dynamic IP so i will keep checking

It is a start

Edited by limelect

Share this post


Link to post

For "general discovery" you will need a ping / port scanner. I wrote a fairly simple one a couple of years ago with DNS lookups:

 

Capture.PNG.5d90b31094fa5ca6f61fa3843ad98fe7.PNG

 

However, if you are looking for a specific program, you only need to display hosts where you find your application listening.

Share this post


Link to post

If you are only looking for your own application running on a phone, an easier solution than ARP or scanning with ping  is to use UDP broadcasts in some way, that is how most devices discover each other on a LAN.  One device listens on a unique port, and responds with it's IP address and details when it hears a broadcast. 

 

Angus

 

  • Like 1

Share this post


Link to post

Right now NOT very good news with Delphi.

My test reference is the above program on my Android s6.

As seen it shows a lot of the 10... ip's including my wife's phone, my phone, my PC, and more.

As for Delphi.

I have used @Angus Robertson suggestion and used "Delphi Developer" in it I took

magiphlp30 program and from it I took the ARP part.

1. In the Android program the output is very stable and consistent.

  I manage to run it on Android Studio and if someone wants

the source I will be glad to share it.

2. In the Delphi program the  ARP dynamics is VERY unstable giving only a few of the 10... IP's . 

I also tried to add IP>name without any good results either.

So this is where I am

P.S in java, the name is taken from "getCanonicalHostName"

host.hostname = (InetAddress.getByName(host.ipAddress)).getCanonicalHostName();

 

 

 

Edited by limelect

Share this post


Link to post
8 hours ago, aehimself said:

For "general discovery" you will need a ping / port scanner. I wrote a fairly simple one a couple of years ago with DNS lookups:

 

Capture.PNG.5d90b31094fa5ca6f61fa3843ad98fe7.PNG

 

However, if you are looking for a specific program, you only need to display hosts where you find your application listening.

@aehimself  This is my own and free quiet extensive

http://limelect.com/downloads/my-ip/

with a lot of goodies inside. And with Delphi obviously.

Edited by limelect

Share this post


Link to post

APR only shows the IP addresses your PC has attempted to connect to, you also need to ping them or connect with UDP/TCP, then the ARP table will fill up.  

 

IP Helper does not have reverse DNS lookup, that is part of all standard internet packages, ICS, Indy, etc, as is ping and open a connection.  But you wanted MAC addresses for some reason, and that is what ARP gives you. 

 

Angus

 

Share this post


Link to post

@Angus Robertson

So returning to my basics any suggestions?

Can you point me to something specific I can go from here?

As you understand I want to duplicate the Android program but with PC

Edited by limelect

Share this post


Link to post

I have already given you all the information you need to write such an application.  I'm not aware of free source code that you can copy.

 

Angus

 

Share this post


Link to post
2 hours ago, limelect said:

with a lot of goodies inside.

Good for a school project; I don't see any other purpose for applications which - mostly - do things what a built-in Windows command does.

If a user doesn't know how to invoke them from the command line they most probably don't need / shouldn't use.

 

11 hours ago, Angus Robertson said:

use UDP broadcasts in some way, that is how most devices discover each other on a LAN.  One device listens on a unique port, and responds with it's IP address and details when it hears a broadcast.

Even I already used this in one of my applications I completely forgot about this. Yes, for finding your own software on a network segment UDP broadcasting is the way to go.

 

I might be completely wrong on this one, but afaik broadcasts can not be relayed to an other subnet, though. Never tried it and didn't work with broadcasts since, so take this with a grain of salt.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×