C
- Home /
- Categories /
- C
Sockets and Network Programming in C
In this hyper-connected electronic world, knowing how to send and receive data remotely with sockets is crucial. In this article, we will see how a socket is essentially a digital “plug” that we can attach to a local or remote address in order to establish a connection. We will also explore the architecture and system calls that allow us to create not only a client but also a server in the C programming language.
Read MoreSending and Intercepting a Signal in C
Anyone who’s ever been confronted to segfaults and bus error will already be familiar with the idea of signals. We get a SIGSEGV or a SIGBUS which ends our program’s execution without notice, without explanation and without appeal. But what really is a signal? Is it more than just the operating system’s police baton? And how can we send, block and even intercept one within our programs? That’s what we will discover in this article.
Threads, Mutexes and Concurrent Programming in C
For efficiency or by necessity, a program can be concurrent rather than sequential. Thanks to its concurrent programming and with its child processes or threads and mutexes, it will be able to perform multiple tasks simultaneously.
Read MoreErrno and Error Management in C
Underlying any software development is program error detection and analysis. But then an external library function or system call fails, how can we understand what went wrong? These functions usually return -1 or NULL, but they also store the reason behind their failure in errno.
Pipe: an Inter-Process Communication Method
By default, it is difficult to get two processes to communicate with each other. As we’ve seen in a previous article, even parent and child processes don’t share the same memory space. So we need to find ways to establish inter-process communication. One of these communication mechanisms is the pipe.
Read MoreHandling a File by its Descriptor in C
The available system calls to create or open, read, write, and delete a file in C all make use of a file descriptor. So let’s discover how the operating system handles references to open files and how to manipulate files in our programs.
Read MoreCreating and Killing Child Processes in C
In order to execute another program within ours or to execute part of our program simultaneously, it can often be very useful to create child processes. Then, all we need to do is patiently wait for them to finish their tasks, or, if we’re feeling particularly murderous, kill them prematurely!
Read MoreLocal, Global and Static Variables in C
A variable is a name we give to a memory storage area that our program can then manipulate. We can specify its size and its type depending on the values it will contain (char, int, long). But we can also control its lifespan and its scope when we declare it. This is why we need to be able to distinguish between local, global and static variables when we program in C.
Read MoreMalloc: Allocating Memory in C
In compiled programming languages ​​like C, it is often useful, or even necessary, to allocate memory dynamically on the heap, in order to accommodate variables of larger or uncertain size. The malloc function allows us to ask the operating system to allocate an area of ​​memory to be used in our program.
Read More