Solved

How to find subnet mask

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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.…
What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
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…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

837 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