need a way to synchronize processes

I am writing a program in C for my networking class, so I am relatively new to this.
To begin, I have 7 processes that need do send messages to every other one, and every one of them needs to receive the messages sent by others.

I am using fork() to create 6 more processes.
The message sending should be done through UDP sockets. So I create 6 sockets for sending using bind() and then I do sendto()

After that the processes call receivefrom()
The problem is that sometimes the process does not catch the sent message, and so the program keeps on waiting for the rest of messages.
I try to rearrange sending and receiving, but ofcourse the scheduler does its own thing. I realize it needs a way to make them wait for each other, I am just not sure how to do it.

Thank you for any help!

Use a mutex or possibly a sempahore set to each value 1 - 6 (or whatever)
There are several ways to implement IPC - interprocess communication -
Read chapter 5 here:
Download Advanced Linux Programming