First plenary session: basic socket API

In the first session, we looked mostly at the basic socket API.

Simple use of the BSD socket API

Code examples from the first plenary session.

 

Other topics we touched upon:

The perhaps most important UNIX command there is: man

The answers you seek are very often found in the manual pages (aka. manpages).

Need to figure out what header file to include to use recv? man recv holds the answer and more.

Be aware that the manual pages are actually divided into several sections - sometimes the same title exists in several of them.

Case in point: bind is also a shell-builtin, documented in section 1, so a simple man bind is not going to be useful when you need documentation about the socket API system call. Look it up in section 2, the system calls manual, instead: man 2 bind.

Not sure what the manpage you need is called? You can perform a simple search using the apropos command.

You'll also find many online versions of the manpages, such as https://manpages.debian.org/. Just take care that they refer to (approximately) the same combination of operating system type and version as you are working on.

A useful tool for network testing: netcat

Another very useful utility for interacting with sockets and network systems in general is netcat (usually available as nc as well). See man nc.

Publisert 30. aug. 2019 15:45 - Sist endret 4. sep. 2019 15:03