Click to See Complete Forum and Search --> : Raw socket not receiving data when matching UDP socket is present


ajay.lele
September 14th, 2009, 07:44 PM
Hi,

I am writing an application where IP TOS value in incoming UDP packet needs to be echoed back in the reply UDP packet (platform is XP..it also needs to work on Vista)
To achieve this, I am trying to use raw socket to read the packet and get the value of TOS byte and a UDP socket along with Traffic Control APIs to set the TOS value in reply packet. Why 2 sockets..why not use the raw socket itself to send the reply? - thats because packets sent from raw socket seems to bypass TC. I have posted that question on another thread but no luck so far
http://social.msdn.microsoft.com/Forums/en-US/networkqosqwave/thread/c23f4bda-6313-461c-9f5c-4c9bc9d7d46b

So with the 2 socket approach, the issue I am facing is that, raw socket is not able to see packets coming for the UDP socket (I mean packets destined for port to which the UDP socket is bound). As soon as I close the UDP socket, next packet received which is destined for this port causes recvfrom() on the raw socket to return. In this scenario, is there a way for the incoming packet to be received by raw socket (I dont care if receive works for UDP socket)


Thanks in advance