title: Linux socket and multi threaded program
body: <p>I have to write simple client-server application that uses Unix datagram socket. Client may send information to server on the request from the server or he may receive information from server on the request from himself. </p>
  
  <p>I have an idea that one thread will be waiting for user input that determines what request we want to send to the server, and the other thread will just wait for message on the socket from the server, if it is the message we requested it will write it to standard output, if it is the server request thread would write what server requested. I would use mutex so the two threads won't write at the same time to the same socket.</p>
  
  <p>My question is, how the sockets will behave if one thread will read from some socket and at the same time other thread will be sending data using the same socket, is it safe? Or should I use mutex for this situation also?</p>