Solved

How to find subnet mask

Posted on 1998-08-10
5
2,750 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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

As more and more people are shifting to the latest .Net frameworks, the windows presentation framework is gaining importance by the day. Many people are now turning to WPF controls to provide a rich user experience. I have been using WPF controls fo…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

756 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