Erl-interface
Kent Boortz
kent@REDACTED
Thu Dec 12 00:33:55 CET 2002
"Eduardo Figoli" <eduardo@REDACTED> writes:
> I don't understand very well how ports in C/C++ can be use in an
> asynchronous way.
> The port needs the caller PID (Process ID) to answer for a request after a
> certain amount of time has passed and other requests to the port where made
> (async).
> How can the port know the PID to answer to ?
> Should I pass the PID to my port (C program) ?
You mean that you have an external C/C++ program? This sound as a
general asynchronous request/reply problem, you have to identify who
you are to send the answer to somehow. You could pass the pid to the
port program or use the port owner as a proxy where you let it save
the mapping between a request identifier (an integer) and the pid of
the process that are to get the answer. If the "clients" waiting for
the answers can die and you want to pass on a cancellation to the port
program you can "monitor" or "link" to the client processes. This way
the proxy get a message when they terminate and can send on the
information to the port program.
All messages from the port are sent to the port owner so you need
to use it to pass on the messages from the port program to the
client anyway.
I may misunderstand what you want to do,
kent
More information about the erlang-questions
mailing list