TCP/UDP
Applications can use Transmission Control Protocol (TCP) and User Datagram Protocol (UDP) services with the TcpClient, TcpListener, and UdpClient classes. These protocol classes are built on top of the System.Net.Sockets.Socket class and take care of the details of transferring data.
The protocol classes use the synchronous methods of the Socket class to provide simple and straightforward access to network services without the overhead of maintaining state information or knowing the details of setting up protocol-specific sockets. To use asynchronous Socket methods, you can use the asynchronous methods supplied by the NetworkStream class. To access features of the Socket class not exposed by the protocol classes, you must use the Socket class.
TcpClient and TcpListener represent the network using the NetworkStream class. You use the GetStream method to return the network stream, and then call the stream's Read and Write methods. The NetworkStream does not own the protocol classes' underlying socket, so closing it does not affect the socket.
The UdpClient class uses an array of bytes to hold the UDP datagram. You use the Send method to send the data to the network and the Receive method to receive an incoming datagram.
See Also
Concepts
Using TCP Services
Using UDP Services
Using Streams on the Network
Using an Asynchronous Server Socket
Using an Asynchronous Client Socket
Using Application Protocols