How do we get the local machine's hostname as seen by the rest of the network?
Annoyingly, gethostname() returns "localhost," which is useless, as does gethostbyname() and uname().
What I actually want is the hostname RoadShow registers with the DHCP server, and that Avast's Wifi Inspector detects when it scans the network. That is, I want the name that other computers on the LAN could use to identify the machine.
Hans
This code
returns the correct hostname for me
eg
Though that is not not quite what you want as that hostname is local to my SAM 440 on the rest of the network it's defeined as SAM in the various local hosts databases. Using fixed ips on my network so the router doesn't knw the hostnames of the machines.
So what does the hostname command return?
eg here on my SAM I get:
which matches up.
Do you actuall want the hostname or just the host address?
Interesting. Is that what you defined in your Internet prefs "Hosts" section?
I really want the hostname that the machine will be identified as by other machines on the network, and NOT just the IP address (which can change; some routers even lack the functionality to choose static IPs).
Hans
Join the Kea Campus - upgrade your skills; support my work; enjoy the Amiga corner.
https://keasigmadelta.com/ - see more of my work
Yes that is the domain associated with the machine IP in hosts.
It may change from boot to boot, but should surely be constant for a given session?
I'm not sure how to get it if the domain name is unknown though.
Being constant for a given session isn't guaranteed. Even if it were, it's still not helpful. I need a human readable name, not an address.
Hans
Join the Kea Campus - upgrade your skills; support my work; enjoy the Amiga corner.
https://keasigmadelta.com/ - see more of my work
Hans,
In Workbench Explorer, turn on Preview Pane, go to Computer, what does the line "Network device name:" say for you? The name you want?