i read that there are several ways to create sockets, through TcpClient/TcpListener, Socket and UdpClient classes. is there any difference between TcpClient/TcpListener and the Socket class? I mean, how do i know which one to use?
The Socket class is an implementation of classic Berkeley Sockets. The TcpClient and TcpListener is specific to Microsoft.
Use Socket if you're already familiar with writing BSD socket calls, or porting a Socket library program to .NET
Use TcpClient and/or TcpListener if you're starting from scratch and are going 100% .NET development, as the TcpClient has a method called GetStream(), that returns a NetworkStream object. You can then hook that up to all the existing stream functionality in .NET (cryptography, file I/O, compression, etc.).
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.