How to identify the origin of a message using Unix module functions
Subject: How to identify the origin of a message using Unix module functions
Newsgroups: gmane.comp.lang.ocaml.beginners
Date: 2008-11-01 23:00:59 GMT
Hi,
I'm using OCaml to implement a library for a network application where
many distributed processes running and communicating. A process can
generate and send messages to others, or pass messages it receives
*without* any modification.
The only requirement is that when a process gets a message, it must be
able to identify whether this message was previously generated by itself
(and circulate back), or by another process but running on the same
machine, or by processes on other machines.
For that, we are allowed to prefix message strings with any kind of tag
when it's generated. The problem is what the tag should look like? Even
simpler, we can assume all the processes start and end at the same time,
so there is no problems about pid/IP reuse.
My naive attempt is using hostname + pid as the tag, but two machines
can named themselves the same but still communicate well if they choose
to always connect through explicit IP, can't they?
If I instead use ip + pid, how can I detect the ip of a running process
without forcing users to always provide one explicitly?
Unix.gethostbyname(Unix.gethostname()) only returns 127.0.0.1, and what
if a machine has several IPs?
The problem turns out be what is unique for a host machine in a
networked application? It seems simple but I don't really know what's
the common idiom. Any suggestion is welcome. Thanks in advance.
--
code17
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch format to Traditional
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe
__,_._,___
RSS Feed