Minitalk is in the second ring of the Core Curriculum @42Wolfsburg. 42 minitalk project is a collaboration between emomkus and qduong Our goal: 1. to practice git branching 2. collaborate together on project
The only requirements are:
- GNU make (v3.81)
- GCC (12.0.0) (clang-1200.0.32.28)
Those versions are the ones used during development.
-
Download/Clone this repo
git clone https://github.com/qduong42/42_minitalk
-
cd
into the 42_minitalk/srcs directory and runmake
cd 42_minitalk/srcs make
After running make, execute ./server
from the same folder. You should see Server pid: X
Open another terminal in the same folder 42_minitalk/srcs and run ./client X [message-to-send]
Examination shows that we may use kill(USERSIG1, PID) kill(USERSIG2, PID) functions to signal the individual bits of characters of string. kill(USERSIG1, PID) may mean 0 and kill(USERSIG2, PID) may mean 1. Out of these bits server shall accumulate 8bit characters.
we use << shift operator, & bitwise AND and other bitwise operators to access individual bits
Technical Documentation of signal.h It explains that we shall define a struct sigaction to use function sigaction(). The technical documentation (https://pubs.opengroup.org/onlinepubs/009695399/basedefs/signal.h.html) defines function's sigaction() operation. Notice the argument data types:
int sigaction(int sig, const struct sigaction *restrict act, struct sigaction *restrict oact);
const struct sigaction
or
struct sigaction
It accepts struct sigaction in the same behabiour as any other datatype (int, char, char *). Contents of struct sigaction are predefined in signal.h library and are listed in technical documentation (https://man7.org/linux/man-pages/man2/sigaction.2.html).
struct sigaction {
void (*sa_handler)(int);
void (*sa_sigaction)(int, siginfo_t *, void *);
sigset_t sa_mask;
int sa_flags;
void (*sa_restorer)(void);
};
- void (*sa_handler)(int) - pointer to a signal handling function. This function receives the signal number as its only argument.
- void (*sa_sigaction)(int, siginfo_t *, void *) -- dependant on architecture or flags, is used instead of sa_handler.
- sigset_t sa_mask -- specifies a mask of signals which should be blocked.
- sa_flags -- specifies a set of flags which modify the behavior of the signal like SA_SIGINFO.