minitalk

by bhagenlo

written for version 2

Hey there!

Welcome to my favourite project so far. It is nice, clean, and short, and you spend most of your time learning about stuff, not debugging some nasty piece of code with dubious pointer and memory errors in it.
I'm sure you'll like it, too :)

#Pre & During

Okay: What do you need to start?
The hard part about this project is, in my opinion, to know how to do what you have to do.

But first things first.
You have to build two seperate executables, a server and a client, which should communicate with each other. For that, the client should be able to send a message (a string) to its server.
Which brings us to the next question: How can two seperate processes interact in UNIX at all?

And the answer is: Via signals.

You have two of them at your disposal: SIGUSR1 and SIGUSR2.
With those, you have to somehow encode the information you want to send.

So, how could you encode information with only two different states?

Hmm, let me think. With two states? You mean, like, 0 and 1?
That sounds a lot like to me.

And once you've understood that, the only thing left is:

How do you destruct and reconstruct your message on both sides?

Want a hint? Via

And now that you've got a good idea about how you can do things, you should be good to go :)

#Cleaning Up

Well, not so much in here. If you've tested it, and it works, you should be fine.
(+ No leaks, segfaults, only one global variable – the standard stuff.)

#Aftercare

Weell – you now can send general signals to any process you know the ID of. So why only send SIGUSR1 & SIGUSR2?
Send the following to your server:
(well, shoot at might fit better, in those cases.)

  • A segfault: SIGSEGV
  • A bus error: SIGBUS
  • Terminate the process: SIGTERM
  • And, finally – kill the process: SIGKILL
  • And if you haven't got enough fun so far: You can get a pretty comprehensive list with

    $ kill -l

    or on your favourite manpage.

That was nice, wasn't it?
See you again soon.

And may your signals ever reach their destination.

#Pointers

← push_swap

Found something to improve? Edit this page on Github!

pipex →