Hi,
UdpSocket is... UDP. Again, NSS.
The main difference is that an UdpSocket will have a sender and destination port, and the packets will have an UDP header. In order to receive an UDP packet, of course, the sender will have to match exactly the receiver port.
An IP raw socket is totally different. It does have just the IP header, and nothing more. The receiving end will have to figure out everything, and it could receive also "unwanted" things. E.g., your Rx socket could be receiving the ARP messages (it is, indeed). Shortly put, Ip RAW sockets is how you create and send ICMPs and stuff like that. However, you need a special care when you receive through a RAW socket, because you'll receive almost everything.
It is possible, of course, to add filters to the RAW sockets, but (again) you need to know what to filter.
As a side note, in the code you posted the "port" is totally ignored when you use a RAW socket... you'd have to use a "protocol" instead, but to set it you need to use
SetProtocol (or the corresponding attribute).
Funny enough, when you receive a packet, the protocol is stored in the port value of the InetSocketAddress. Weird but it's how it works.
Hope this helps,
T.