Re: pipes
- From: Rainer Weikusat <rweikusat@xxxxxxxxxxx>
- Date: Wed, 29 Aug 2007 20:43:36 +0200
CptDondo <yan@xxxxxxxxxxxxxxxx> writes:
[...]
From what I gather, I'm better off using BSD mmap, rather than SysV
IPC... Right?
I think mmap is easier to use.
And in essence, all I have to do on the server is something like:
fd = open(somefile,O_WRONLY);
mmap(some block, PROT_WRITE....,fd)
then write to fd and do a msync????
Assuming a suitable file exists:
fd = open(somefile, O_RDWR);
p = mmap(NULL, length_of_data, PROT_READ | PROT_WRITE, MAP_SHARED,
fd, 0);
close(fd)
Afterwards, you can just use the memory area pointed to by 'p' like
any other memory area.
On the client,
fd = open(somefile,O_RDONLY);
mmap(some block, PROT_READ....,fd)
fd = open(somefile, O_RDONLY);
p = mmap(NULL, length_of_data, PROT_READ, MAP_SHARED, fd, 0);
close(fd);
Both 'client p' and 'server p' will point the same area of physical
memory from now on. 'msync' is only needed if you want to ensure that
changes are written to disk. You will need to come up with some sort
of 'access protocol' to ensure that the client doesn't read from the
same part of this area the server is currently writing to.
.
- Follow-Ups:
- Re: pipes
- From: CptDondo
- Re: pipes
- Prev by Date: Re: multi-process locking
- Next by Date: Re: multi-process locking
- Previous by thread: Re: pipes
- Next by thread: Re: pipes
- Index(es):
Relevant Pages
|