03-19-06 05:02 PM
"Henrik Goldman" <henrik_goldman@mail.tele.dk> wrote in message
news:dvhbe2$j7q$1@news.net.uni-c.dk...
>
> There are various reasons why I dislike sockets. One of them beeing that
> it takes a amount of work to do proper synchronization since e.g. recv()
> could return less then the message size.
Only for stream sockets. You say "it takes a amount of work" - I'm not sure
whether you mean coding or processing, but neither are usually significant
in my experience. ("Partial" recv() calls can happen, but usually don't if
messages are small, and are usually not a major performance factor if
messages are large.)
> Also the software is deployed at computers which I have no control over.
> Therefore I don't want to publish a service which could be portscanned
> and possibly abused.
You could allow the service to be bound to the loopback address or use Unix
domain sockets.
> I think I'll go for message queues. Does anyone know some information
> about speed of message queues? E.g. how high cost do they have?
>
> I found that all posix implementations since around 1993 should have
> mqueue.h and have functions like mq_open and it's friends.
I think support is not universal, and msgget/ctl/snd/rcv are more readily
available.
However, sockets seem likely to be a more natural fit for the problem (I am
guessing - since you didn't answer - that the protocol is request/response,
but message queues give unidirectional IPC) and sockets-based IPC can of
course be multiplexed with network I/O between the cache service and the
server. Using sockets also leaves open the option of having the cache
service running remote from the clients with minimal code changes. Finally,
you are presumably already familiar with sockets so there is nothing (or
less) to learn.
I don't know about performance, but I can't see any reasons for substantial
differences with the different IPC methods except that shared memory might
be optimal. For a shared memory scheme to be significantly better, it
probably needs to be implemented with care, and even then the gain is likely
to be small unless messages are large.
Alex
[ Post a follow-up to this message ]
|