#include <old.h>
#define OLD_PORT
int old_connect( char *host, int port);
int old_lock( int fd, char *s);
int old_unlock( int fd, char *s);
int old_trylock( int fd, char *s);
It provides an abstract, high level interface to the normal locking operations so that any application can use the server without having to worry about the underlying layer.
old_connect() is special because it must be called before any other, and is used to establish the network connection with the lock server. It accepts two parameters: the first one is a string identifying the host to connect, which can be an IP address or the name of the host which will be resolved; and the second one is the port to connect to, it should be the same one the server is expecting connections. When possible, use the default defined in OLD_PORT.
old_lock() is used to lock the given resource, and it will block until the lock is granted. It returns 1 on success, and -1 if there was a fail in delivering the command to the server.
old_unlock() releases the lock on the given resource. It returns 1 on success, 0 on failure (for example if the object wasn't locked in the first place), and -1 if there was a failure in delivering the command to the server.
old_trylock() attempts to lock the resource, but does not block. It returns 1 if the object was locked, 0 if not (because it was locked and it would block), and -1 if there was a failure in delivering the command to the server.