I'm writing a server where, because of the modeless of the protocol, I'll need to use flock() on files, rather than filehandles. One request will lock a file, another will do a read/write, and then I'll receive an unlock request. The server forks between requests. What's the best way to do this, since flock() operates on filehandles and not files? I'd like to keep this server as portable as possible, although my only real concern is that it works on Linux.