473,387 Members | 1,423 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Receiving Icmpv6 messages via C#

Hi,
As part of an application I'd like to capture Icmpv6 packets thrown
when an application is not listening on a given port. I.e. I send a
packet to another host on a port and listen for Icmp destination
unreachable,port unreachable messages. While this method works for
Icmpv4 on C# it doesn't for Icmpv6. ( I'm using .net 2.0) I also know
that this packet is been sent by the other host as I can view the
Icmpv6 packet via Ethereal. ( It is a host unreachable , port
unreachable packet). I've posted the code I'm using below, if anyone
has any ideas I'd really appreciate it. The receive call blocks
indefinitely ( if no timeout is set).

Socket pingSocket = new Socket(
AddressFamily.InterNetworkV6,
SocketType.Dgram,
ProtocolType.Udp);
Socket pingSocket2 = new Socket(
AddressFamily.InterNetworkV6,
SocketType.Raw,
ProtocolType.IcmpV6);
string data = "Syslog test message";

IPAddress destAdd =
IPAddress.Parse("2002:a155:624b::a155:624b");
IPEndPoint ipep = new IPEndPoint(destAdd, 514);
IPEndPoint ipep2 = new IPEndPoint(IPAddress.IPv6Any, 0);

EndPoint ep = (EndPoint)ipep2;
string destAddress = destAdd.ToString();
ASCIIEncoding asc = new ASCIIEncoding();
byte[] myArray = asc.GetBytes(data);
byte [] recBuffer = new byte[0x140];
try {
pingSocket2.ReceiveTimeout = 1000;
pingSocket2.Bind(ep);
pingSocket1.SendTo(myArray, myArray.Length,
SocketFlags.None, ipep);
pingSocket2.ReceiveFrom(
recBuffer,
ref ep);
Console.WriteLine("Received {0} bytes ",
recBuffer.Length);
}
catch(Exception e)
{}
}
}

Thanks,
Piyush

Dec 7 '06 #1
0 1145

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: valexena | last post by:
I am attempting to take tablespace offline and receiving the following error: ORA-01546- cannot take tablespace offline. What I am doing wrong? -- Posted via http://dbforums.com
0
by: Luc | last post by:
Hi, I am making an application that receives Asynchronous Soap messages over a TCP connection. As it stands right now, if two messages are close together, the receiver misses the second one, I...
3
by: Jason | last post by:
I'm trying to implement some pretty basic behavior in c#/.net 1.1 Forms but can't seem to find all the requisite pieces. When a user clicks on the background of the form, I want the app to start...
1
by: Kishore Gopalan | last post by:
Hi, I have a strange trouble. My application sends messages to a local MSMQ Queue (say 'A') and I use a listener (a windows service) to move the messages to another local queue (say 'B') and my...
8
by: Brian | last post by:
Hi, I come from a C background. I am trying to receive messages over a serial port. The message data structure format is along the lines of int message_id; int message_length; int data; ...
3
by: Tony Clark | last post by:
Hi, I am creating a network application and want to use SOAP messages to communicate between clients (I am not consuming a web service!!), does anyone know of any good tutorials (or sample code)...
0
by: justsovanilla | last post by:
Hi, As part of an application I'd like to capture Icmpv6 packets thrown when an application is not listening on a given port. I.e. I send a packet to another host on a port and listen for Icmp...
3
by: kirany82 | last post by:
i have different types of messages coming from Client. for example.. struct Hello { int opCode; char fileHash; }; struct Details { int IP; int Port; int count; }; the size and format of the...
6
by: globalrev | last post by:
can i send and receive messages from a website using python? how would that work with costs? would the mobileowner pay both ways?
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...

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.