Solved

How to find subnet mask

Posted on 1998-08-10
5
2,747 Views
Last Modified: 2013-12-03
I'm trying to send a broadcast on a TCP/IP LAN. I'm going to use the subnet mask to build a broadcast address.
Is there a function in Win32 (or MFC) to find out the subnet mask? Or if not, how do I make a broadcast?
0
Comment
Question by:zingo
  • 2
  • 2
5 Comments
 
LVL 2

Accepted Solution

by:
connex earned 50 total points
Comment Utility
Well there is no direct function to get the subnetmask, but you can read it from the registry *yuck*.
Maybe it's easier simply to make a socket broadcasting .)
See the documentation of SetSocketOpt and/or
the Chatter Samples which use broadcasting.

connex


0
 
LVL 11

Expert Comment

by:alexo
Comment Utility
* Check the bindings in HKLM\Enum\Root\Net\xxxx\Bindings for a MSTCP binding
* The driver for the binding is found in HKLM\Enum\Network\MSTCP\yyyy
* The driver points to System\CurrentControlSet\Services\Class\nettrans\zzzz

0
 

Author Comment

by:zingo
Comment Utility
The chatter example does not use broadcast, it just connects to a server. The server then forwards all messages to all connected clients.

I've looked at the SetSockOpt SO_BROADCAST thing, but one question remains then: What do I use as address when calling SendTo(...) (CAsyncSocket).
0
 
LVL 2

Expert Comment

by:connex
Comment Utility
Well the sample that I have here uses broadcasting to find a server.

Anyway, following is taken from the SendTo help:

To send a broadcast (on a SOCK_DGRAM only), the address in the lpSockAddr parameter should be constructed using the special IP address INADDR_BROADCAST (defined in the Windows Sockets header file WINSOCK.H) together with the intended port number. Or, if the lpszHostAddress parameter is NULL, the socket is configured for broadcast. It is generally inadvisable for a broadcast datagram to exceed the size at which fragmentation can occur, which implies that the data portion of the datagram (excluding headers) should not exceed 512 bytes.

What's unclear about that?


0
 

Author Comment

by:zingo
Comment Utility
Nothing is unclear, anymore. I tried it and it works. The problem was that I didn't read all the way down in the help text. Real silly.

Thanks,

              Zingo
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This article shows how to make a Windows 7 gadget that accepts files dropped from the Windows Explorer.  It also illustrates how to give your gadget a non-rectangular shape and how to add some nifty visual effects to text displayed in a your gadget.…
After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now