in reply to flocking a socket

The following text from my Solaris man page for flock() would seem to indicate that you can't do this:

Locks are on files, not file descriptors. That is, file descriptors duplicated through dup(2) or fork(2) do not result in multiple instances of a lock, but rather multiple references to a single lock. If a process holding a lock on a file forks and the child explicitly unlocks the file, the parent will lose its lock. Locks are not inherited by a child process.

I'm guessing that you are trying to coordinate reads or writes between the parent and child. I think that restating the higher-level problem you are trying to solve would be more helpful.