I am currently working on a project to learn about signals, basically I have clients and servers , The server Pid on which I should have the input as a parameter with the string with the client, after the launch, the customer sends this string to the server and the server displays it.
What I have done so far is the string in the binary and if the integer is a 0 then I otherwise send SIGUSR1 (if it is 1) I send the SIGUSR2, in this way I want to convert binary to string I am thinking but how can I do this?
Here the main one is for the server, as you can see that it shows its PID (so we can launch the customer after this) and are waiting for the signal. Once it gets hold of one, it calls my_sig (which you will find later in this thread).
int main () {int pid; Pid = getpid (); Printf ("Server is Paid:% d \ n", pid); If (sign (SIGUSR1, my_sig) == SIG_ERR) {printf ("Error. \ N"); Exit (1); } If (sign (SIGUSR2, my_sig) == SIG_ERR) {printf ("Error. \ N"); Exit (1); } While (1); }
And here's my simple simplest my_sig, as you can see that it receives the SigrousR 1 as the signal, it displays a 0, otherwise 1.
zero my_sig (int param) {char * src; Four * destination; If (param == SIGUSR1) {my_printf ("0"); } If (param == SIGUSR2) {my_printf ("1"); }}
What it does at the end of the day, the word given in the client is displayed in binary four characters.
How do I use it? Edit: As much as I would like to know about other signals, I would love to know about other signals, unfortunately, I I am limited to the projects.
No comments:
Post a Comment