Okay, the code you posted doesn't look like it has any problems. Please post the smallest client and server programs you can create that produce this problem.
EDIT: Please also show the command you use to compile, any output from the compiler, and any instructions or data files we need to replicate the problem.
I've found the bug :) The problem was that i had a
where buf is but the real received buf was only 5 chars!
recv(f_sockd, buf, sizeof(buf), 0);
So i have changed the above instruction to:
and now all works perfectly :D :D :D
recv(f_sockd, buf, 6, 0);