Posts: 1,298
Threads: 38
Joined: Sep 2016
Could you not just query your "host" file (provided you use it, of course

)
If it ain't broke, I just haven't gotten to it yet.
OS: Windows 10, openSuse 42.3, freeBSD 11, Raspian "Stretch"
Python 3.6.5, IDE: PyCharm 2018 Community Edition
Posts: 1,298
Threads: 38
Joined: Sep 2016
May-11-2017, 02:03 PM
(This post was last modified: May-11-2017, 02:03 PM by sparkz_alot.)
I've never tried it, but you could possibly use the broadcast ip of 255.255.255.255 (which is for the 0.0.0.0 network which is your network). Note this never gets routed. You could also try using the Data Link layer of Ethernet by sending the broadcast to MAC FF:FF:FF:FF:FF:FF.
If you are using IPV6, all bets are off cuz it uses "multicast" instead of "broadcast".
Another avenue you might try is to search
PyPI for packages related to ARP and see if any of them look promising.
EDIT:
I should also add, the broadcast address is almost always 255 as in 192.168.1.255
If it ain't broke, I just haven't gotten to it yet.
OS: Windows 10, openSuse 42.3, freeBSD 11, Raspian "Stretch"
Python 3.6.5, IDE: PyCharm 2018 Community Edition
Posts: 1,298
Threads: 38
Joined: Sep 2016
Let's remember that the subnet mask is only used to separate the 'network' part of the address from the 'host' part of the address. It doesn't matter if the address is 10.x.x.x or 192.x.x.x . If I have the addresses 10.1.2.3 (A) and 10.1.2.4 (B) with a subnet mask of 255.255.255.0 we are saying that 10.1.2 is the network portion and .3 and .4 are the hosts portion and they can talk directly since they are on the same network and applies to the whole range 10.1.2.0 thru 10.1.2.255. If we change the address of B to 10.1.255.4, they are no longer part of the same network and so the broadcast address (the last octet being 255) will be different for both, one for each network. If you change the subnet mask to 255.255.0.0, A and B are once again in the same network (10.1) with the same broadcast address. By convention, a final octet of '0' is the entire network and the final octet of '255' is the broadcast address (I will add that, though not etched in stone, many network admins will use the final octet of '1' for the primary router).
Sorry to be long winded, but I wanted to make sure that current and future readers can have an understanding of what we are talking about here.
Back to your situation, if all you want to do is broadcast to the subnet (or 'hosts') you simply have to ensure the final octet = 255. You shouldn't need to know the subnet mask of each computer. That has already been designated. What you really need is the IP address of the computer running your script, change the final octet to 255 and your done. Unless your script is building or re-building the network.
If it ain't broke, I just haven't gotten to it yet.
OS: Windows 10, openSuse 42.3, freeBSD 11, Raspian "Stretch"
Python 3.6.5, IDE: PyCharm 2018 Community Edition