Sockets Programming

Programming applications that access a network was originally a complicated affair, but with the .NET Framework, this is no longer the case. The .NET Framework provides classes that substantially simplify complex network programming. These classes are in the System.Net and System.Net.Sockets namespaces in the System.dll assembly.

The most important class for network programming is System.Net.Sockets.Socket. The Socket class abstracts and implements the Socket API and/or Berkeley socket interface standard.

The Socket API was developed at the beginning of the 1980s at the University of California,Berkeley for Berkeley Software Distribution (BSD) UNIX.

A socket is an endpoint of a connection. With sockets, you can read and send data to and from a network on both the client and server sides. To send or receive data from a socket, you need to know the IP address of the other communication partner (endpoint) and one agreedupon port number, which can vary depending on application purposes. A client application, thus, must know the IP address of the server and connect with that server on a particular port.

The server listens on the agreed port or ports and accepts incoming connections from one or more clients.