Solved

How to find subnet mask

Posted on 1998-08-10
5
2,751 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 2

Accepted Solution

by:
connex earned 50 total points
ID: 1413304
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
ID: 1413305
* 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
ID: 1413306
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
ID: 1413307
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
ID: 1413308
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

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

With most software applications trying to cater to multiple user needs nowadays, the focus is to make them as configurable as possible. For e.g., when creating Silverlight applications which will connect to WCF services, the service end point usuall…
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
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…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

751 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