Search code examples
socketstcpudpbuffer

Preserve UDP packets in the OS buffer after "receiving" them


I am working on Windows with C# but this is more of a general question. If I receive UDP packages with a UDP client they are normally removed from the receive buffer so other programs can no logner access this data. My experiments showed that this is not the case for boradcast messages. If I connect multible programs to the same UDP port and call the receive function both application can see the broadcast packages, but only one application can see unicast packages as they are deleted when first read by the OS?? I guess...?

My question is is there a way to change this socket behaviour? can I set up my socket to preserve this data so a second programm could access it as well? Or is this not possible?

the overall goeal as you can guess is to have multible programs receive the same UDP packagees send via Unicast.


Solution

  • After alot of research i can confirm this is not possible with unicast packages. You can use PCAP to achive this but not with the native UdpClient