in what kind of a relation are Socket and UdpClient classes in C#?
Could the relation be described by a one of the design patterns?
UdpClient is a wrapper around a socket using UDProtocol. It's similar to the TCPClient, all it does is provide yet another layer of abstraction to make network programming that much easier.
Update:
Also, I never really understood why some people prefer UDPClient and TCPClient over using the base socket class. It can give you an ample start to learn network programming in .NET without too much pain, but I feel the more layers of abstraction you have that the less you will understanding of what is going on under-the-hood. I feel that this makes it much harder in the long run to debug complex or weird behaviorial problems in your code because so much of what is going on is hidden from you, because you are several layers high in abstraction. Even the .NET Socket class is a layer of abstraction as its a wrapper around a native (Berkeley Sockets Interface) socket, and I never really felt that network programming in native C++, for example, was that difficult either.
Though, if you follow standards, guidelines and write high quality code you may not have any problems at all (minus environmental and circumstantial problems), but I always recommend learning the base Socket class so you have a better understanding of .NET networking. I guess it all depends on how deep you are interested in learning the framework and becoming an expert on the subject.
In short conclusion, either way is generally okay based on your requirements and necessity, but I always recommend learning over abstraction any day.
Based on danderson's response, it sounds a little like the Facade pattern.
A facade can: make a software library easier to use, understand and test, since the facade has convenient methods for common tasks;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With