What do network programmers do

Network programming with sockets

Sockets encapsulate the details of network communication. The programmer can thus concentrate on the implementation of the application. Ideally, the applications function independently of the programming language, operating system and network interface.

The Socket API is supported by all common operating systems. Sockets are based on the protocols of a transport layer such as TCP or UDP. From the point of view of the application, a socket is access to the network. In the following we will discuss the programming using the example of the programming language C. The use in other programming languages ​​is similar. At the end of this chapter we show an implementation in the Perl language.

The Socket API provides two methods: connection-oriented and connectionless communication. In the first case, the two computers involved must first establish a connection before they can exchange data. In both cases, however, one of the two computers - the server - takes on the task of first setting up the network resource. Then it waits for connection requests from the other computer - the client. A server can generally serve several clients. Sockets are not only suitable for communication between computers. You can also handle communication between several applications on one computer.

You can also find this article in our compendium “tecCHANNEL-Compact Network Know-How”, which you can get free of charge order in our online shop can. You can obtain the source code of the following examples for direct transfer into your programming environment if you select the link "Text view" under the listings. You can find the complete source code of the Compact here to download.