IPv6 Mulicast in C#

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hi ,
I am trying to catch IPv6 Packets. I have done this for IPv4 My code is working fine. But when I modified same code for Ipv6 it does not work. Below is the code for Ipv4 which is in working state... Can anyone help me to modify the code for Ipv6?
When I give command as ipconfig /renew6, I want to capture packtes here...

static void Main(string[] args)<br/>
{<br/>
Thread mythread = new Thread(new ThreadStart(IPv6Packet));<br/>
mythread.Start();<br/>
<br/>
mythread.Join();<br/>
}
private static void IPv6Packet()<br/>
{<br/>
Console.WriteLine("Ready to recieve the packet:n");<br/>
Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);<br/>
<br/>
try<br/>
{<br/>
IPEndPoint endPoint = new IPEndPoint(IPAddress.Any, DHCPDiscovery.BroadcastPort);<br/>
socket.Bind(endPoint);<br/>
//Assign Address to client<br/>
while (true)<br/>
{<br/>
<br/>
try<br/>
{<br/>
socket.SetSocketOption(SocketOptionLevel.Socket,<br/>

SocketOptionName.ReceiveTimeout,<br/>

DHCPDiscovery.Quickly);<br/>
<br/>
byte[] byteMessage = new byte[1024];<br/>
socket.Receive(byteMessage, 0, byteMessage.Length, SocketFlags.None);<br/>
<br/>
Console.WriteLine("Recieved following packet:n");<br/>
for (int i = 0; i < byteMessage.Length; i++)<br/>
{<br/>
Console.WriteLine("byteMessage[" + i.ToString() + "] = " + byteMessage.ToString() + "n");<br/>
}<br/>
}<br/>
catch (SocketException socketException)<br/>
{<br/>
//Console.WriteLine(socketException.Message);<br/>
continue;<br/>
}<br/>
}<br/>
}<br/>
catch (Exception Ex)<br/>
{<br/>
Console.WriteLine(Ex.Message);<br/>
socket.Close();<br/>
}<br/>
}
If I do ipconfig /renew then I should get the packet, which I can get with above code for IpV4 but not for IPv6!

I have tried using IPv6 Apis for above code but it wont work, Can anyone guide me how I can modify above code for IPv6?
Thanks,
Ajit

View the full article
 

Similar threads

P
Replies
0
Views
179
Policy standard local admin account with Active Di
P
B
Replies
0
Views
78
Bikky Kumar Rai
B
M
Replies
0
Views
147
MyCatAlex
M
Back
Top