File locking between server threads
There is no reason to use flock and  a mutex, unless you are sharing
with another process (as opposed to thread).  I would just use the mutex and
remember to check the return values from the pthread_* and write calls.

Some other comments:


name in write_to_file should be const and the write call in that
function should use the length of the name, not an assumed 20.
you need to check the status of function calls (read, write, send
etc).
depending upon where the data being written is coming from and what it
contains, you may have byte-ordering problems that are not handled.
Since you are mixing string data and dat_com structures on the socket, you
risk getting them mixed up.  You'd be better sticking with one format, maybe
strings and have a way to check alignment and log/recover-from errors.
Your fprint calls are not synchronized across threads and may end up
interleaved.
When sending the name, there is no need to copy it into a string first.

sprintf(str_send,"%s",incm_dat-&gt;name);
send(this_fd,str_send,sizeof(incm_dat-&gt;name),MSG_NOSIGNAL);


just send it directly:

send(this_fd, incm_dat-&gt;name, strlen(incm_dat-&gt;name), MSG_NOSIGNAL);

Your variable and type names are poorly chosen.  dat_com means little,
this_fd should be just fd, incm_dat could be just data, o_fd as a
global should be longer and more descriptive of function.