Hello.
I'm developing an app that needs to connect to a PC server over LAN. The easy way is, of course, having the user type an IP and port and voila...
But I'd like to find a way to keep user input (regarding networking) to a minimum.
So, instead of manually typing IP's, I used
which outputs
Now, the IP part is taken care of, but do you guys know how I can find the machine's name (for example, my PC's called Slave, my laptop MobileSlave etc... )? Is this part possible?
I did find a way posted somewhere around here, namely
But this seems to simply return the same IP I input.
Any thoughts?
I'm developing an app that needs to connect to a PC server over LAN. The easy way is, of course, having the user type an IP and port and voila...
But I'd like to find a way to keep user input (regarding networking) to a minimum.
So, instead of manually typing IP's, I used
B4X:
p.Shell("cat /proc/net/arp", Null, sb, Null)
B4X:
bla bla
192.168.0.129 0x1 0x2 d0:57:7b:a7:80:dc * wlan0
bla bla
Now, the IP part is taken care of, but do you guys know how I can find the machine's name (for example, my PC's called Slave, my laptop MobileSlave etc... )? Is this part possible?
I did find a way posted somewhere around here, namely
B4X:
Sub GetHostName(IP As String) As String
Dim r As Reflector
r.Target = r.RunStaticMethod("java.net.InetAddress", "getByName", Array As Object(IP), _
Array As String("java.lang.String"))
If r.Target = Null Then Return "N/A"
Return r.RunMethod("getCanonicalHostName")
End Sub
But this seems to simply return the same IP I input.
Any thoughts?