Android Question Show computers on connected network

Albert Kallal

Active Member
Licensed User
Is there a library kicking around for B4A that will show computers on a network I am connected to (it would be Wi-fi - to a local windows network).

I did a quick search - saw the B4A network library and thus am considering to cook somthing up, but no real need to re-invent the wheel here.

There are out in the "wild" a few samples for android via Google. Perhaps it time to learn how to include these external .jars into my android apps.

This is not a high priority request - but something that spits out a list of computers (and of course their IP address) has a number of use cases I can think of.

Regards,
Albert D. Kallal
Edmonton, Alberta Canada
 

drgottjr

Expert
Licensed User
Longtime User
this can get you started:
B4X:
Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    'Activity.LoadLayout("Layout1")
    Dim ph As Phone
    Dim stdout As StringBuilder
    stdout.Initialize
    Dim stderr As StringBuilder
    stderr.Initialize
    Try
        ph.Shell("cat", Array As String("/proc/net/arp"), stdout, stderr)
        Msgbox(stdout.ToString, "stdout:")
        Msgbox(stderr.ToString, "stderr:")
    Catch
        Msgbox(LastException.Message, "No arp at this time")
     End Try
    
    Try
        ph.Shell("ip", Array As String("neighbor"), stdout, stderr)
        Msgbox(stdout.ToString, "stdout:")
        Msgbox(stderr.ToString, "stderr:")
    Catch
        Msgbox(LastException.Message, "No ip at this time")
    End Try
End Sub

but there are a number of issues.  you should research "arp android" for a better understanding.
 

Attachments

  • arp.png
    arp.png
    46 KB · Views: 197
  • ip.png
    ip.png
    38.6 KB · Views: 200
Upvote 0

Albert Kallal

Active Member
Licensed User
Thanks - I much looking for somthing like how the popular xfile simply just shows a list of computers on the LAN.

So, xfile shows this:
(only me on my home network right now).

xfile22.png


So all I do is click on LAN in above, and I can see the list of computers.

As noted, there are some samples floating around and a few jar libraries that will simply return the list of computers on the LAN like xfile (popular file manager) is doing above.

It not really a must do, but I looking towards listing out the computers - and then list out which ones have a active instance of SQL server.

I could perhaps figure out the way to do this with UDP - but it looks to be more work then what this is worth to me.

I just wanted to add a "lib" to my grab bag of tools - then I could drop this into say my app using jDBC bit of code that is hitting SQL server. Toss in a browse network, then I can select the sql server - grab the IP address, and then grab data from that instance of SQLs server.

If I find something that easy to use and that spits out a nice clean list or collection of computers on a network (that I am connected to by wi-fi) - I'll share it here.

Regards,
Albert D. Kallal
Edmonton, Alberta Canada
 
Upvote 0

Albert Kallal

Active Member
Licensed User
Can you post a link to such sample?

Example of solution based on UDP broadcasting: MQTT Chat with Auto Discovery
To be fair - I was in the context of some apps that do this. (solid explorer)
eg:
I can't recall if in my Goog travels that I came across a "reasonable" example. (I hit quite a few sites today).

I played (actually today!) with the CFIS/CMB examples on this forum - and they work rather well.
eg:

Some "very" interesting reading on this subject - this article suggests that "legacy" pipes that exist on the network may be a "easy" way to do this:

it suggests that using "pipes" that exist on networks could give the result
eg:
\MAILSLOT\BROWSE =The Mailslot name used by the Windows NT Browse Service.
\MAILSLOT\LANMAN =The Mailslot name used by the older LAN Manager Browse Service.

So, above might one possible easy path (but the above is rather "older legacy" when it comes to windows.
But, I was thinking this suggests something like this with CFIS might be possbile:

SMB1.ListFiles("smb://ALBERTKALLAL-PC/MAILSLOT/LANMAN/", "") would be a potential approach.
or:
SMB1.ListFiles("smb://MAILSLOT/LANMAN/", "") would be a potential approach (however, this is a knowledge area I don't have - not at all sure how pipes work, or are supported).

My spider sense is that most solutions likely use some kind of UDF approach - and rotate say on the assumed 192.0.0.1 range. (but I am not sure).

I might have missed that UDF is not too much work to "get" the computers on the LAN.

And to be fair, I did not want to push too much on this issue here. I found the above read and link on cifs browsing a VERY interesting article never the less.

Where I was going with this?

Well I have jDBC working really nice with SQL server. (using jtds-ds driver). I can't believe how easy this was.
(the B4A candy store here is really impressive!!! - always finding what I want! Keep me out of these examples! - I not getting any work done!).

And I felt so bad in reading about jDBC + jtds. I wanted to "stop" and post some help! I saw so many posts around the internet with people having trouble using the library. The problem is they all NEAR miss the fact that SQL server for some time now enforces the requirement to specify the named instance of SQL server. I may well post on forums here how one must specify the named instance - if one does not, then jDBC will not seem to work. Setting the named instance of SQL server thus makes it work all so easy. (anyway - I am getting off topic!).

So, with jDBC working, then I thought, golly gee, why not add something that "lists" out computers, and then from that lists out instances of SQL server on the network!
And if that works, then why not display the databases. And from that, click on a table. And then display some data!
So, a cute sql browser app that lets you choose a table and view it. And it would be a great "tester" to see if sql server allows jDBC connections on the network.

However I don't want to lean too hard on a solution unless it "kind of easy" or something exists kicking around that makes this easy.

I'll take a look at the MQTT chat - that was quite much next on my list (and I realize that this may well not provide a list of computers or devices on the network).

Regards,
Albert D. Kallal
Edmonton, Alberta Canada
 
Upvote 0
Top