|
|
How to use named pipes?
This is my first attempt to write a server, so I'd
appreciate some guidance from you folks out there.
My application has to generate a big hash and then
perform searches on that structure every once in a
while. The hash contents (it is a K-D tree) are
constant and every minute or so there is a query
of the nearest neighbor in the tree. I simply hate
having to reconstruct the fixed tree every time the
program starts. So I figure I need a client-server
architecture. The server assembles the big tree and
just waits for queries. I suspect that something called
a "named pipe" would be appropriate here but I need help
with the implementation details (or perhaps there is
a suggestion for a better solution?).
The client program has to place a point (two integer
numbers) in the pipe and somehow expect the results
(a set of a few points) to be produced by the server.
A named pipe can be seen in the filesystem, right?
I don't have my Unix books handy. Is there any sample
code, or tutorial around?
TIA,
-Ramon F Herrera
|
|
0
|
|
|
|
Reply
|
ramon (1465)
|
1/25/2005 9:00:15 AM |
|
I am going to be more specific in my posting.
My server will spend most of its time doing nothing, and
I am trying to decide how to wait in an efficient manner.
Should the server simply open the named pipe for reading
and then the process will just block for a long time until
finally there is something to be read form the pipe?
It this a efficient implementation? Or perhaps the server
should do some sleep() and check the status of the
pipe (how?) periodically before attempting to read it??
-Ramon
|
|
0
|
|
|
|
Reply
|
ramon (1465)
|
1/25/2005 11:15:14 AM
|
|
Ramon F Herrera wrote:
> I am going to be more specific in my posting.
>
> My server will spend most of its time doing nothing, and
> I am trying to decide how to wait in an efficient manner.
>
> Should the server simply open the named pipe for reading
> and then the process will just block for a long time until
> finally there is something to be read form the pipe?
>
> It this a efficient implementation? Or perhaps the server
> should do some sleep() and check the status of the
> pipe (how?) periodically before attempting to read it??
>
> -Ramon
>
If your server spends most of it's time doing nothing, there will be no
need for doing that efficiently, IMO.
There is no difference between being blocked in a read() or in a
select() or poll(). You could even block on a sleep or wait: won't cost
you nothing, except for the block.
Instead of a pipe you could use a socket connection. No difference for
your program, basically. A bit more difficult setting up, but a few
advantages.
HTH,
AvK
|
|
0
|
|
|
|
Reply
|
moi
|
1/25/2005 11:47:47 AM
|
|
As far as pipes are concerned, I think I saw something like blocking and
non-blocking pipes. The blocking pipes should sleep automatically until
a message arrives.
Other possibility for writing a server is to use sockets. Try to look at:
http://www.amk.ca/python/howto/sockets/
It is a small howto for sockets in Python. You can make like that a very
small (in code length) and you do it very fast (in time spent) server
client application.
Petr.
Ramon F Herrera wrote:
> I am going to be more specific in my posting.
>
> My server will spend most of its time doing nothing, and
> I am trying to decide how to wait in an efficient manner.
>
> Should the server simply open the named pipe for reading
> and then the process will just block for a long time until
> finally there is something to be read form the pipe?
>
> It this a efficient implementation? Or perhaps the server
> should do some sleep() and check the status of the
> pipe (how?) periodically before attempting to read it??
>
> -Ramon
>
|
|
0
|
|
|
|
Reply
|
lorenzp (1)
|
1/25/2005 12:46:13 PM
|
|
|
3 Replies
30 Views
(page loaded in 0.059 seconds)
Similiar Articles: Pipes - Named or Anonymous - comp.os.ms-windows.programmer.win32 ...I am planning to use pipes with proxying & marshaling to do this. I am confused as to how to make a decision on whether to use named or anonymous pipes for this? oracle export utility and named pipes. - comp.unix.solaris ...hi, I have been using export utility to take backup of our database. with the old export utility I used to run the following to successfully take the... bidirectional pipe question - comp.lang.tclHi, I am using a bidirectional pipe to filter data through a Unix command, but for some ... Stack Overflow I have 2 apps that I want to make communicate via named pipes ... Where do message queues, named pipes reside? - comp.unix ...One basic question: What is the actual physical storage place for message queues and named pipes? Do they exist as part of disk or memory always, impl... Pipe command outputs to file without overwriting ... - comp.unix ...Hi, How can i use the pipe command to write terminal outputs to the same file without being overwritten ..... Currently i am using the command ... whi... C pipe error - comp.unix.programmerHallo, Am using pipes in my C code to talk to a child process that I have forked. However, I keep on getting an certain erro messge that I cannot und... jpg to mpg? - comp.graphics.apps.gimpI haven't had problems when using mplayer to play a sequence of jpegs while sending the output to stream.yuv, a named pipe, and "cat"ting that into yuvscaler and them ... EOF on pipe - comp.unix.programmerSending an EOF to a named pipe - Unix Linux Forum - Fixunix.com I'm using named pipes in a bash script and I can't figure out how to send an EOF so that the reader can exit. Capture the stdout of another process. - comp.unix.programmer ...I suppose you could do use named pipes to read the output in a different process. Still, there might be a much better way, for all I know. What exactly is it you want ... How to pipe in an input list of files to awk - comp.lang.awk ...Is there a simple one line command (without using foreach) to run awk on all files in ... Two-way pipe on an awk process - comp.lang.awk How to pipe in an input list of files ... How to: Use Named Pipes to Communicate Between Processes over a ...Named pipes offer more functionality than anonymous pipes. This functionality includes full duplex communication over a network and multiple server instances; message ... 7/25/2012 4:44:46 PM
|
|
|
|
|
|
|
|
|