我需要编辑UDP数据包的标头(并使用已编辑的标头发送),我想我必须使用原始套接字。
我试过这样的事情:
byte[] buffer = new byte[]{0x00,0x00};
string ip = "SomeIP"
Socket sk = new Socket(AddressFamily.InterNetwork, SocketType.Raw, ProtocolType.Raw);
sk.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.HeaderIncluded, true);
sk.SendTo(new byte[] { buffer }, new IPEndPoint(IPAddress.Parse(ip),2017));
但我仍然无法编辑标题:(
答案 0 :(得分:0)
byte[] buffer = new byte[] { 0x00, 0x00 };
string ip = "SomeIP";
// Set Socket Type to 'Dgram' for connectionless and UDP since your working with UDP
Socket sk = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
sk.SendTo(buffer, new IPEndPoint(IPAddress.Parse(ip), 2017));