Jump to content
Sign in to follow this  

using broadcast adress with tcp/ip

Recommended Posts


hi all im trying to figure something out here

i want to write a script that uses the network for starting updates and some other things.

that my parrents keep forgeting to do.

sending information over the net as well.

so i'm trying to write a script that i can use so that they don't have to.

i want to capture my ip adress this i know how ( @ipadress1)

but now i want to change the last bit of it in to a broadcast adress 255

example my ip is

now i save this in a variable and i want to make it so that i change the adress to:

this way i can update all computers at once. >_<

a badly written code is better than a unwritten onea good written code is even better.but there is always room for improvement. :)

Share this post

Link to post
Share on other sites

You are not being very clear about what you want to do but anyways: you can use StringInStr() to find the position of the last DOT in the ipaddress and use StringLeft() to retrieve that section.


SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource        Forum Rules
Live for the present,
Dream of the future,
Learn from the past.

Share this post

Link to post
Share on other sites


Edited by playlet

Share this post

Link to post
Share on other sites

here's the right way to do it >_<

MsgBox(0 , "" , "Broadcast address example" & @CRLF & _
                     " - : " & BC_ADDR("" , "") & @CRLF & _
                     " -         : " & BC_ADDR("" , "") & @CRLF & _
                     " - : " & BC_ADDR("" , ""))
MsgBox(0 ,"Broadcast address for @IpAddress1" , GET_BROADCAST(@IPAddress1));for GET_BROADCAST you need to use an ip that is allocated

    $objWMIService = ObjGet("winmgmts:{impersonationLevel=Impersonate}!\\" & @ComputerName & "\root\cimv2")
    If Not IsObj($objWMIService) Then Exit
    $colAdapters = $objWMIService.ExecQuery ("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True")
    For $objAdapter in $colAdapters
        If Not ($objAdapter.IPAddress) = " " Then
            For $i = 0 To UBound($objAdapter.IPAddress)-1
                If $objAdapter.IPAddress($i)=$IP Then Return BC_ADDR($objAdapter.IPAddress($i),$objAdapter.IPSubnet($i))
    Return 0
    Local $BC=""
    $IP=StringSplit($IP , ".")
    $MASK=StringSplit($MASK , ".")
    If $IP[0]<>4 Then Return SetError(1,0,0)
    If $MASK[0]<>4 Then Return SetError(2,0,0)
    For $i=1 To 4
    Return StringTrimRight($BC,1)

p.s.: tcp can't broadcast ... but udp can

Edited by Xand3r

Only two things are infinite, the universe and human stupidity, and i'm not sure about the former -Alber EinsteinPractice makes perfect! but nobody's perfect so why practice at all?http://forum.ambrozie.ro

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this