Here's a modification of the code above that counts back fro the .255 address to the current IP, significantly reducing the work in most cases, as well as speeding things up:
As a side-note: you can see another significant speed increase by reducing the UDP timeout period, although I am not sure how that would be affected on slow networks adapters... during my tests UDPTimeout of 0 or 1 worked without problems as well, finishing the code above almost instantaneous for all adapters.
;==================================================== ;BROADCAST IP DETERMINIFICATIONALIZOMATICIFIERTRON v3 ;==================================================== hadapters=CountHostIPs("") Dim bcastip(hadapters) stream=CreateUDPStream(8123) UDPTimeouts 5 For x=1 To hadapters bcastip(x)=HostIP(x)-(HostIP(x) Mod 256) + 255 Notify DottedIP$(bcastip(x)) Repeat WriteString stream,"HELLO SAILOR" SendUDPMsg stream,bcastip(x),8123 recv=RecvUDPMsg(stream) nmsg$=ReadString$(stream) bcastip(x)=bcastip(x)-1 Until nmsg$="HELLO SAILOR" Or bcastip(x)=HostIP(x) If nmsg$="HELLO SAILOR" Then Notify "NIC ("+x+") Broadcast IP: "+DottedIP$(bcastip(x)+1) If recv=0 Then bcastip(x)=0:Notify "Failed to determine NIC("+x+") broadcast IP." Next CloseUDPStream stream
As a side-note: you can see another significant speed increase by reducing the UDP timeout period, although I am not sure how that would be affected on slow networks adapters... during my tests UDPTimeout of 0 or 1 worked without problems as well, finishing the code above almost instantaneous for all adapters.