473,698 Members | 2,029 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

MS .NET VS C++ and Socket Class doing Raw IP ReceiveFrom

2 New Member
I'm using MS VS C++ .NET. I've written a multicast test utility that can
send IGMP packets for a user specified group address. As well, it can
send and receive UDP packets for a specified multicast group. I'm using
the Sockets Class methods for sending and receiving packets. One area I'm having problems with is recieving IGMP packets on the Raw IP socket.

Here is the main calls I am using to receive IGMP packets.
Expand|Select|Wrap|Line Numbers
  1.     s = new Socket(AddressFamily::InterNetwork, SocketType::Raw, 
  2.                             ProtocolType::Igmp);
  3.     s->SetSocketOption(SocketOptionLevel::IP, 
  4.                                   SocketOptionName::MulticastInterface, 0);
  5.     s->Bind(new IPEndPoint(IPAddress::Any,0));
  6.  
  7.     IPEndPoint* sender = new IPEndPoint(IPAddress->Any, 0);
  8.     EndPoint* tempRemoteEP = __try_cast<EndPoint*>(sender);
  9.     Byte buffer[] = new Byte[1024];
  10.     Console::WriteLine(S"Waiting on socket.");
  11.     s->ReceiveFrom(buffer, 0, 1024, SocketFlags::None, &tempRemoteEP);
  12.  
I see the debug WriteLine I put in that it is waiting on the socket. I'm using Wireshark to watch for IGMP Queries/Reports on the wire and see IGMP
messaging, but my test module is not receiving these. I've tried various
other Socket Options, etc. and haven't had any success. I've read some
info on Bind that a 0 causes Bind to generate a enphemoral port number.
Since I'm trying to do Raw IP do I bind or do I need some value other than
0 for bind? I haven't been able to find any examples or info anywhere on
the Web and I've fallin into the mode of just trying various options from
the Socket Class. Kinda like rolling dice. Any one have any experience
in setting up to receive Raw IP with MS VC++?
May 14 '07 #1
1 2706
ssherm01
2 New Member
This is an update to my post for information:
I found reference to the Socket.I0Contro l() function that allows a code
as a parameter. One of the codes I found reference to at the MSDN
URL : <http://msdn2.microsoft .com/en-us/library/system.net.sock ets.iocontrolco de.aspx>.
This identifies an IOControlCode of ReceiveAllIgmpM ulticast.
However I get a compile error of not a class of namespace on IOControlCode.
May 14 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
1695
by: Dan Rice | last post by:
Hello, Im trying to get the following working but it doesn't seem to receive anything. I have got the UdpClient class to receive data but unreliably and was told to use the Socket class directly. Here's the code: Dim lep As New IPEndPoint(IPAddress.Any, 0) Dim s As New Socket(AddressFamily.InterNetwork,
3
7791
by: Stephan Steiner | last post by:
Hi I have a small program listening to UDP broadcast datagrams that are periodically sent out. It will stop listening for a certain period if either a sufficient number of packets has been received (this is triggered from a class not in the sample code), or if there has been no data on the net for a certain period. During the time where I don't want any packets, I set my socket receive buffer size to zero. The problem is, when I used...
1
3076
by: Rolln_Thndr | last post by:
I'm vey new to network programing and have a few rather fundemental questions. I'm creating a very basic UDP proxy server and having a few issues regarding the sockets. Is it possible to change the properties of a socket WITHOUT closing it and creating a new one? Basically, I need to change the port of a bound socket, but the only way I have found to do this so far is to close the exisitng socket and create a new one. This in itself...
2
1819
by: Richy Rich | last post by:
Hi, I've developed an application in C# which spawns a thread to receive datagrams. If I use the socket receive method, there are no problems when using the application under NT or XP. I recently moved over to using the UdpClient receive method. This was so I could record the IPEndPoint from
5
11690
by: Terry | last post by:
It's my understanding of UDP sockets that if there is a thread blocked on a "recvFrom()" call and other thread sends a UDP packet to some address, that if the machine on the other end isn't up, that the "recvFrom()" call should just continue blocking. Right? What I'm seeing is that when I send a packet to a particular address that is not responding, my "recvFrom()" call throws an exception. I get "An existing connection was forcibly...
10
12196
by: Jim H | last post by:
I have a UDP socket that sends out a request on a multicast socket and waits for a response. This client is not listening on a multicast IP but the local IP. The server (UNIX) responds to the sender's IP. Using debug files on the server I see the server receive the request from my application on my machine and I see the server send to the correct IP and port of my machine, but the ReceiveFrom never returns with any data. If I have a...
0
1068
by: Ron L | last post by:
I am trying to write a program that will open a UDPClient and listen on it. I have based my code on the example at MS in the "UDPClient.Receive Method (.NET Framework)" file, but when I try to call the .Receive method I get the following exception: System.Net.Sockets.SocketException: An invalid argument was supplied at System.Net.Sockets.Socket.ReceiveFrom(Byte buffer, Int32 offset, Int32 size, SocketFlags socketFlags, EndPoint&...
1
4403
by: Nuno Magalhaes | last post by:
Does the function below returns an UDP packet, for example, from the local machine? Why does it give me an error: "The best overloaded method match for ReceiveFrom... has some invalid arguments". Why this error? How can I receive a packet from a specific adapter, for example, my local machine? Is there a better way? This way won't work. The error is in "ref ep"... how does receiveFrom work? Thanks.
0
1520
by: Johan | last post by:
Why is the parameter remoteEP of the function Socket.ReceiveFrom() a ref parameter and not an out parameter? http://msdn2.microsoft.com/en-us/library/wdfskwcy.aspx public int ReceiveFrom ( byte buffer, ref EndPoint remoteEP )
0
8672
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9156
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9021
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8892
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8860
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7712
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6518
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
2
2323
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
1998
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.