Click here to Skip to main content
16,004,782 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionHow to disable task menu item? Pin
no_body6920-May-03 1:16
no_body6920-May-03 1:16 
AnswerRe: How to disable task menu item? Pin
Rickard Andersson2020-May-03 3:29
Rickard Andersson2020-May-03 3:29 
GeneralRe: How to disable task menu item? Pin
Rickard Andersson2020-May-03 3:30
Rickard Andersson2020-May-03 3:30 
GeneralRe: How to disable task menu item? Pin
no_body694-Jun-03 23:53
no_body694-Jun-03 23:53 
GeneralSOCKET & BROADCAST Pin
borini19-May-03 23:50
borini19-May-03 23:50 
GeneralRe: SOCKET & BROADCAST Pin
Rickard Andersson2020-May-03 3:23
Rickard Andersson2020-May-03 3:23 
GeneralRe: SOCKET & BROADCAST Pin
borini20-May-03 4:05
borini20-May-03 4:05 
GeneralRe: SOCKET & BROADCAST Pin
Rickard Andersson2020-May-03 5:00
Rickard Andersson2020-May-03 5:00 
3.8 - How do I send a broadcast packet?
With the UDP protocol you can send a packet so that all workstations on the network will see it. (TCP doesn't allow broadcasting.)

To send broadcast packets, you must first enable the SO_BROADCAST option with the setsockopt() function. Next you have to figure out the "directed broadcast" address, which means "send this packet to all stations on this LAN". To construct the directed broadcast address, use the following C code:

u_long host_addr = inet_addr("172.16.77.88"); // local IP addr
u_long net_mask = inet_addr("255.255.224.0"); // LAN netmask
u_long net_addr = host_addr & net_mask; // 172.16.64.0
u_long dir_bcast_addr = net_addr | (~net_mask); // 172.16.95.255
Potential Problems: Broadcasts can be useful at times, but keep in mind that this creates a load on all the machines on the network, even on machines that aren't listening for the packet. This is because the part of the stack that can reject the packet is several layers down. As a result, most routers drop simple broadcast packets, and sometimes even drop directed broadcasts to nearby networks. (A simple broadcast is one sent to address 255.255.255.255.) The practical upshot of this is that sometimes broadcasts won't work at all, and even when they do work they cause unnecessary loads on the network. To get around these problems, you may want to consider multicasting instead.



http://tangentsoft.net/wskfaq/intermediate.html#broadcast[^]

Rickard Andersson8
Here is my card, contact me later!

UIN: 50302279
E-Mail: nikado@pc.nu
Interests: C++, ADO, SQL, Winsock, 0s and 1s


GeneralRe: SOCKET & BROADCAST Pin
borini20-May-03 10:09
borini20-May-03 10:09 
GeneralComboBox Control Pin
Member 34035519-May-03 23:35
Member 34035519-May-03 23:35 
GeneralCListCtrl advanced - loading Pin
JensB19-May-03 23:16
JensB19-May-03 23:16 
GeneralRe: CListCtrl advanced - loading Pin
Neville Franks20-May-03 0:28
Neville Franks20-May-03 0:28 
GeneralRe: CListCtrl advanced - loading Pin
Dominik Reichl20-May-03 0:40
Dominik Reichl20-May-03 0:40 
GeneralRe: CListCtrl advanced - loading Pin
JensB20-May-03 2:11
JensB20-May-03 2:11 
GeneralRe: CListCtrl advanced - loading Pin
Niklas L20-May-03 2:34
Niklas L20-May-03 2:34 
GeneralRe: CListCtrl advanced - loading Pin
JensB20-May-03 2:51
JensB20-May-03 2:51 
GeneralRe: CListCtrl advanced - loading Pin
Peter Mares20-May-03 6:01
Peter Mares20-May-03 6:01 
GeneralRe: CListCtrl advanced - loading Pin
JensB20-May-03 6:14
JensB20-May-03 6:14 
GeneralSilly ZIP question Pin
doctorpi19-May-03 23:12
doctorpi19-May-03 23:12 
GeneralRe: Silly ZIP question Pin
JensB19-May-03 23:30
JensB19-May-03 23:30 
GeneralRe: Silly ZIP question Pin
doctorpi19-May-03 23:33
doctorpi19-May-03 23:33 
GeneralRe: Silly ZIP question Pin
Dominik Reichl20-May-03 0:50
Dominik Reichl20-May-03 0:50 
GeneralFastest Pin
Tomas Wilhelmsson19-May-03 22:39
Tomas Wilhelmsson19-May-03 22:39 
GeneralRe: Fastest Pin
jhwurmbach19-May-03 23:51
jhwurmbach19-May-03 23:51 
GeneralRegistry functions Pin
Rage19-May-03 22:18
professionalRage19-May-03 22:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.