Click here to Skip to main content
15,913,333 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralWhat's that? I can't add more variables in a class - then the whole program doesn't work! Pin
bond00615-Jun-03 6:06
bond00615-Jun-03 6:06 
GeneralRe: What's that? I can't add more variables in a class - then the whole program doesn't work! Pin
Harsha Gopal15-Jun-03 15:57
Harsha Gopal15-Jun-03 15:57 
GeneralRe: What's that? I can't add more variables in a class - then the whole program doesn't work! Pin
bond00622-Jun-03 2:38
bond00622-Jun-03 2:38 
GeneralSending a raw UDP packet from win9x <br><br>Chris ya need to remove html formatting here ppl can do some nasty things lol Pin
15-Jun-03 4:23
suss15-Jun-03 4:23 
GeneralRe: Sending a raw UDP packet from win9x &lt;br&gt;&lt;br&gt;Chris ya need to remove html formatting here ppl can do some nasty things lol Pin
Kuniva15-Jun-03 4:37
Kuniva15-Jun-03 4:37 
GeneralRe: Sending a raw UDP packet from win9x Pin
Kuniva15-Jun-03 4:39
Kuniva15-Jun-03 4:39 
GeneralRe: Sending a raw UDP packet from win9x Pin
Kuniva15-Jun-03 4:41
Kuniva15-Jun-03 4:41 
GeneralRe: Sending a raw UDP packet from win9x Pin
JohnnyG15-Jun-03 6:19
JohnnyG15-Jun-03 6:19 
I'm a little confused here cuz if you're saying that an application is listening to broadcast UDP packets and it needs the broadcaster's source address, then you don't need raw mode.

Regular Winsock API programming of a UDP socket can transmit a broadcast message which automatically inserts the IP address (as the source IP) of the computer sending the broadcast message. This is handled by Winsock. You simply just setup the in_addr structure with the remote port and IP address that you are sending a message to, setup your data field, and you don't have to put in any of the raw type parameters like length of fields, checksums, source IP address, or anything like that. All of that is done for you. You only have to specify the char array that holds your data and the length of it in the sendto() function.

Oh yeah, I forgot. You also have to do a setsocketopt() with a SO_BROADCAST option. Here's some code:
 WSADATA             wsaData;
 SOCKET              sock;
 SOCKADDR_IN         dst_addr;
 char                sampleMsg[132];
 int                 optval = 1;
 int                 optlen = sizeof(int);

 dst_addr.sin_family = AF_INET;
 dst_addr.sin_port = htons(myPort);
 dst_addr.sin_addr.s_addr = inet_addr("255.255.255.255");

 strcpy(sampleMsg, "This is a test sample msg from the box. ");

 rc = WSAStartup (MAKEWORD (1, 1), &wsaData);
 if(rc != 0)
 {
     // handle error
 }

 // Create a UDP socket
 sock = socket(AF_INET,SOCK_DGRAM, 0);
 if(sock == INVALID_SOCKET)
 {
  // handle error
 }
// Set up the socket to do broadcast messages
 rc = setsockopt(sock, SOL_SOCKET, SO_BROADCAST, (char *)&optval, optlen);
 if(rc == SOCKET_ERROR)
 {
  // handle error
 }

  while(!kbhit())
  {
      printf("Sending data: %s  Any key to quit.\n", sampleMsg);
      rc = sendto(sock, sampleMsg, strlen(sampleMsg) + 1, 0, (struct sockaddr*) &dst_addr, sizeof(dst_addr));
      if(rc == SOCKET_ERROR)
      {
          // handle error
      }
      Sleep(1000);
  }

GeneralRe: Sending a raw UDP packet from win9x Pin
Kuniva15-Jun-03 7:00
Kuniva15-Jun-03 7:00 
GeneralRe: Sending a raw UDP packet from win9x Pin
JohnnyG15-Jun-03 16:00
JohnnyG15-Jun-03 16:00 
GeneralRe: Sending a raw UDP packet from win9x Pin
Kuniva15-Jun-03 22:37
Kuniva15-Jun-03 22:37 
GeneralRe: Sending a raw UDP packet from win9x Pin
JohnnyG16-Jun-03 3:09
JohnnyG16-Jun-03 3:09 
GeneralRe: Sending a raw UDP packet from win9x Pin
Kuniva16-Jun-03 6:05
Kuniva16-Jun-03 6:05 
GeneralHelp me, Full Owner Draw CEdit Control Pin
Anonymous15-Jun-03 3:59
Anonymous15-Jun-03 3:59 
GeneralRe: Help me, Full Owner Draw CEdit Control Pin
Iain Clarke, Warrior Programmer15-Jun-03 5:35
Iain Clarke, Warrior Programmer15-Jun-03 5:35 
GeneralRe: Help me, Full Owner Draw CEdit Control Pin
zjkw15-Jun-03 6:16
zjkw15-Jun-03 6:16 
GeneralDIBs and BMP's Pin
Tommy2k15-Jun-03 2:41
Tommy2k15-Jun-03 2:41 
GeneralRe: DIBs and BMP's Pin
Gary R. Wheeler15-Jun-03 3:07
Gary R. Wheeler15-Jun-03 3:07 
GeneralRe: DIBs and BMP's Pin
Tommy2k15-Jun-03 4:35
Tommy2k15-Jun-03 4:35 
GeneralRe: DIBs and BMP's Pin
Ryan Binns15-Jun-03 5:01
Ryan Binns15-Jun-03 5:01 
GeneralRe: DIBs and BMP's Pin
Ryan Binns15-Jun-03 3:08
Ryan Binns15-Jun-03 3:08 
GeneralRe: DIBs and BMP's Pin
Gary R. Wheeler15-Jun-03 3:30
Gary R. Wheeler15-Jun-03 3:30 
GeneralRe: DIBs and BMP's Pin
Ryan Binns15-Jun-03 3:40
Ryan Binns15-Jun-03 3:40 
GeneralRe: DIBs and BMP's Pin
Tommy2k15-Jun-03 4:43
Tommy2k15-Jun-03 4:43 
GeneralRe: DIBs and BMP's Pin
Ryan Binns15-Jun-03 4:53
Ryan Binns15-Jun-03 4:53 

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.