Try my new website:
www.urcho.com
- the new SIMPLE social network
Sign up
|
357
members |
125
snippets
Search for:
ALL
POPULAR
File Controls
Multiplayer Code
2D Effects
3D Effects
Oldskool demos
Basic Functions
Maths/Physics
Sound
Tutorials
Misc
Username:
Password:
Sign up
getSubnetMask() & getBroadcastAddress() by Jeremy Alessi
[
back
]
Author:
Archive
| Viewed:
1033
times | Language:
BlitzBasic 3D
| Category:
Multiplayer Code
Function getBroadcastAddress$( ip$ ) subnetMask$ = getSubnetMask() bank = CreateBank( 4 ) byte$ = "" j = 1 For i = 0 To 3 byte = "" While Mid( subnetMask$, j, 1 ) <> "." And j < Len( subnetMask$ ) byte$ = byte$ + Mid( subnetMask$, j, 1 ) j = j + 1 Wend j = j + 1 PokeByte( bank, i, byte$ ) Next onesComplement( bank, 0, 4 ) bank2 = CreateBank( 4 ) byte$ = "" j = 1 For i = 0 To 3 byte$ = "" While Mid( ip$, j, 1 ) <> "." And j < Len( ip$ ) byte$ = byte$ + Mid( ip$, j, 1 ) j = j + 1 Wend j = j + 1 PokeByte( bank2, i, byte$ ) Next bank3 = CreateBank( 4 ) For i = 0 To 3 PokeByte( bank3, i, ( PeekByte( bank, i ) Or PeekByte( bank2, i ) ) ) Next broadcastAddress$ = ( PeekByte( bank3, 0 ) + "." + PeekByte( bank3, 1 ) + "." + PeekByte( bank3, 2) + "." + PeekByte( bank3, 3 ) ) FreeBank( bank ) FreeBank( bank2 ) FreeBank( bank3 ) Return broadcastAddress$ End Function
Author Comments:
This combo adds getSubnetMask() to Blitz3D via a .dll and userlib that I wrote in Visual C++ and additionally adds a getBroadcastAddress() function written in Blitz which can be used to ping a LAN of any network class type. I originally created this to "fix" BlitzPlay which is limited to a class-C network assumption and additionally doesnt even use the broadcast address for that assumption but instead pings 255 ip addresses. With this code multiplayer LAN searches can be conducted instantly on any network class. Heres a link to the .dll/userlib www.alessigames.com/codeArchives/ipHelper.zip Theres a onesComplement() function included as well which is used in the getBroadcastAddress() function.
Login or
create an account
to comment on this snippet