linux python ipc module by Walter de Jong <walter@heiho.net> (c) 2003

INTRODUCTION
I was looking for the shmem module or functions in python, and to my
surprise, I could not find any. I googled around and found 2 implementations,
which were not satisfactory because I really wanted the interface to be
as close to the C interface as possible.
So I spend a day messing around with swig and here it is: the python
ipc module.


SUPPORTED FUNCTIONS
The following important functions are in the ipc module:

	ftok()			Create IPC key

	msgget()		Message queues
	msgctl()
	msgsnd()
	msgrcv()

	semget()		Semaphores
	semctl()
	semop()

	shmget()		Shared memory
	shmctl()
	shmat()
	shmdt()

	shmcpy_to()		Copy strings to and from a shared memory segment
	shmcpy_from()

	mkmsgbuf()		Make msgbuf structure for msgsnd()

For further documentation, see the Unix manpages and try 'dir(ipc)'
in python.

There are also functions to create needed structures and unions, like:
new_semun(), new_shmid_ds(), new_msqid_ds()

There are also accessor functions for members of structures, like:
semun_val_set()

These were auto-generated by swig 1.3 (and above).


PORTABILITY
The IPC structures seem to come right out of kernel-land. This means that
the IPC code is tightly bound to the kernel, and may change whenever the
kernel changes. This is not a problem for C code (which ports to different
platforms without much trouble), but it is a problem for swig. The real
problem here is that swig is not able to parse the system header files
(swig's interpreter is not as good as cc's) and as a result I had to make
my own ipc.h, declaring the system structures myself. The exact
implementation of these structures are not portable.
So, if you want to port this ipc module to a platform different from
Linux 2.4, you will have to collect the following files into your
own ipc.h :

    /usr/include/sys/ipc.h
    /usr/include/sys/sem.h
    /usr/include/sys/shm.h
    /usr/include/sys/msg.h

... and possibly more. Remove all the cruft that swig chokes on.

Also be sure to use the latest stable of both swig and python. Chances are
that it will not work otherwise.
I have also seen some issues with using swig on a platform different from
'IA32'. You know what they say, 'Your mileage may vary'.


HOW TO BUILD
Edit the Makefile. Escpecially, check the python include path.
Type 'make'.
You need the development package of python -- if it cannot find the
include file Python.h anywhere, then you need to install the python-dev
package.
You also need to have swig.
See also: http://www.python.org
          http://www.swig.org

If the build succeeds, run python.

>>> import ipc
>>>

If you get an error, something is wrong. Check your version of swig and
python. You may have additional trouble if you're not on an IA32 platform.
If no error messages appear, you are ready to use the ipc module.

>>> dir(ipc)

Have fun from here on ...


Greets,

    --Walter

EOB
