Global Message Passing

I’m trying to pass messages between processes running on different
machines. Both machines are on TCP/IP and the same network segment (both
plug into the same switch.)

My server uses the line:

attach = name_attach(NULL, “myname”, NAME_FLAG_GLOBAL_ATTACH);

My client does:

coid = name_open(“myname”, NAME_FLAG_ATTACH_GLOBAL);

I don’t do anything else to enable global message passing.


If both processes run on the same machine, the message passing works
fine. When I move the client to another machine, they don’t communicate.

What else should I be doing (or what QNX doc should I be looking in to
get help?)

Bruce

Do you have QNET running?
Did you assign hostnames to your computers?
Can you see them in /net directory?

Pavol Kycina

“Bruce Knoth” <bknoth@erg.sri.com> wrote in message
news:3A70C61E.EDE1311C@erg.sri.com

I’m trying to pass messages between processes running on different
machines. Both machines are on TCP/IP and the same network segment (both
plug into the same switch.)

My server uses the line:

attach = name_attach(NULL, “myname”, NAME_FLAG_GLOBAL_ATTACH);

My client does:

coid = name_open(“myname”, NAME_FLAG_ATTACH_GLOBAL);

I don’t do anything else to enable global message passing.


If both processes run on the same machine, the message passing works
fine. When I move the client to another machine, they don’t communicate.

What else should I be doing (or what QNX doc should I be looking in to
get help?)

Bruce

Previously, Bruce Knoth wrote in qdn.public.qnxrtp.os:

I’m trying to pass messages between processes running on different
machines. Both machines are on TCP/IP and the same network segment (both
plug into the same switch.)

My server uses the line:

attach = name_attach(NULL, “myname”, NAME_FLAG_GLOBAL_ATTACH);

My client does:

coid = name_open(“myname”, NAME_FLAG_ATTACH_GLOBAL);

I don’t do anything else to enable global message passing.


If both processes run on the same machine, the message passing works
fine. When I move the client to another machine, they don’t communicate.

What else should I be doing (or what QNX doc should I be looking in to
get help?)

i think you need qnet the QNX network layer configured between your machines.

Bruce

Bruce Knoth <bknoth@erg.sri.com> wrote:

I’m trying to pass messages between processes running on different
machines. Both machines are on TCP/IP and the same network segment (both
plug into the same switch.)

My server uses the line:

attach = name_attach(NULL, “myname”, NAME_FLAG_GLOBAL_ATTACH);

My client does:

coid = name_open(“myname”, NAME_FLAG_ATTACH_GLOBAL);

I don’t do anything else to enable global message passing.



If both processes run on the same machine, the message passing works
fine. When I move the client to another machine, they don’t communicate.

What else should I be doing (or what QNX doc should I be looking in to
get help?)

Assuming that you have qnet running then you are doing the right thing.
Unfortunately the GLOBAL ability is not yet supported between nodes
since it is a function that has to be implemented by the qnet protocol
itself. I believe that this work has been done internally, but is not
on a released version of qnet yet. I was under the impression that
this was in a note describing the currently un-implemented features
of qnet, but we should probably add a note to the name_* documentation
as well.

Thomas

My level of ignorance is high enough that I didn’t know QNET had to run
(didn’t even know it existed.) Learning new OS’s is a challenge.

Any idea on when global message passing will be supported? Should I be looking
at a different technique?

Thanks,
Bruce


Thomas Fletcher wrote:

Bruce Knoth <> bknoth@erg.sri.com> > wrote:
I’m trying to pass messages between processes running on different
machines. Both machines are on TCP/IP and the same network segment (both
plug into the same switch.)

My server uses the line:

attach = name_attach(NULL, “myname”, NAME_FLAG_GLOBAL_ATTACH);

My client does:

coid = name_open(“myname”, NAME_FLAG_ATTACH_GLOBAL);

I don’t do anything else to enable global message passing.

If both processes run on the same machine, the message passing works
fine. When I move the client to another machine, they don’t communicate.

What else should I be doing (or what QNX doc should I be looking in to
get help?)

Assuming that you have qnet running then you are doing the right thing.
Unfortunately the GLOBAL ability is not yet supported between nodes
since it is a function that has to be implemented by the qnet protocol
itself. I believe that this work has been done internally, but is not
on a released version of qnet yet. I was under the impression that
this was in a note describing the currently un-implemented features
of qnet, but we should probably add a note to the name_* documentation
as well.

Thomas

Bruce Knoth a écrit :

My level of ignorance is high enough that I didn’t know QNET had to run
(didn’t even know it existed.) Learning new OS’s is a challenge.

Any idea on when global message passing will be supported? Should I be looking
at a different technique?

Thanks,
Bruce

Thomas Fletcher wrote:

Bruce Knoth <> bknoth@erg.sri.com> > wrote:
I’m trying to pass messages between processes running on different
machines. Both machines are on TCP/IP and the same network segment (both
plug into the same switch.)

My server uses the line:

attach = name_attach(NULL, “myname”, NAME_FLAG_GLOBAL_ATTACH);

My client does:

coid = name_open(“myname”, NAME_FLAG_ATTACH_GLOBAL);

I don’t do anything else to enable global message passing.

If both processes run on the same machine, the message passing works
fine. When I move the client to another machine, they don’t communicate.

What else should I be doing (or what QNX doc should I be looking in to
get help?)

Assuming that you have qnet running then you are doing the right thing.
Unfortunately the GLOBAL ability is not yet supported between nodes
since it is a function that has to be implemented by the qnet protocol
itself. I believe that this work has been done internally, but is not
on a released version of qnet yet. I was under the impression that
this was in a note describing the currently un-implemented features
of qnet, but we should probably add a note to the name_* documentation
as well.

Thomas

Yes, in fact, as far as I know, naming is not the prefered ‘qnx’ way to initiate a
dialog between two applications.
Following Unix fashion, it’s better from the server side, to register a file name
or a directory name by calling resmgr_attach().
From the client side, you only have to call an open() to obtain a file descriptor
to use read(), write(), but you also can you MsgSendxx() to send specific
messages.
You can see an example in ‘Writing a resource manager’ in the doc.

Unfortunately, unlike name_open() can do (or could do), open() can’t find a name
over a network, YOU have to know where is the ‘name’ to open because it’s a
‘classical’ file name. for example : open("/net/distant_machine/tmp/my_server",
…).

Alain.

Alain Bonnefoy wrote:

Bruce Knoth a écrit :

My level of ignorance is high enough that I didn’t know QNET had to run
(didn’t even know it existed.) Learning new OS’s is a challenge.

Any idea on when global message passing will be supported? Should I be looking
at a different technique?

Thanks,
Bruce

Thomas Fletcher wrote:

Bruce Knoth <> bknoth@erg.sri.com> > wrote:
I’m trying to pass messages between processes running on different
machines. Both machines are on TCP/IP and the same network segment (both
plug into the same switch.)

My server uses the line:

attach = name_attach(NULL, “myname”, NAME_FLAG_GLOBAL_ATTACH);

My client does:

coid = name_open(“myname”, NAME_FLAG_ATTACH_GLOBAL);

I don’t do anything else to enable global message passing.

If both processes run on the same machine, the message passing works
fine. When I move the client to another machine, they don’t communicate.

What else should I be doing (or what QNX doc should I be looking in to
get help?)

Assuming that you have qnet running then you are doing the right thing.
Unfortunately the GLOBAL ability is not yet supported between nodes
since it is a function that has to be implemented by the qnet protocol
itself. I believe that this work has been done internally, but is not
on a released version of qnet yet. I was under the impression that
this was in a note describing the currently un-implemented features
of qnet, but we should probably add a note to the name_* documentation
as well.

Thomas

Yes, in fact, as far as I know, naming is not the prefered ‘qnx’ way to initiate a
dialog between two applications.
Following Unix fashion, it’s better from the server side, to register a file name
or a directory name by calling resmgr_attach().
From the client side, you only have to call an open() to obtain a file descriptor
to use read(), write(), but you also can you MsgSendxx() to send specific
messages.
You can see an example in ‘Writing a resource manager’ in the doc.

Unfortunately, unlike name_open() can do (or could do), open() can’t find a name
over a network, YOU have to know where is the ‘name’ to open because it’s a
‘classical’ file name. for example : open("/net/distant_machine/tmp/my_server",
…).

Can NTO use

prefix -A/tmp/my_server=/net/distant_machine/tmp/my_server

as in QNX4 to make “classical” file opens, etc. network enabled?


Alain.

Dean Douthat <ddouthat@faac.com> wrote:


Alain Bonnefoy wrote:

Bruce Knoth a écrit :

My level of ignorance is high enough that I didn’t know QNET had to run
(didn’t even know it existed.) Learning new OS’s is a challenge.

Any idea on when global message passing will be supported? Should I be looking
at a different technique?

Thanks,
Bruce

Thomas Fletcher wrote:

Bruce Knoth <> bknoth@erg.sri.com> > wrote:
I’m trying to pass messages between processes running on different
machines. Both machines are on TCP/IP and the same network segment (both
plug into the same switch.)

My server uses the line:

attach = name_attach(NULL, “myname”, NAME_FLAG_GLOBAL_ATTACH);

My client does:

coid = name_open(“myname”, NAME_FLAG_ATTACH_GLOBAL);

I don’t do anything else to enable global message passing.

If both processes run on the same machine, the message passing works
fine. When I move the client to another machine, they don’t communicate.

What else should I be doing (or what QNX doc should I be looking in to
get help?)

Assuming that you have qnet running then you are doing the right thing.
Unfortunately the GLOBAL ability is not yet supported between nodes
since it is a function that has to be implemented by the qnet protocol
itself. I believe that this work has been done internally, but is not
on a released version of qnet yet. I was under the impression that
this was in a note describing the currently un-implemented features
of qnet, but we should probably add a note to the name_* documentation
as well.

Thomas

Yes, in fact, as far as I know, naming is not the prefered ‘qnx’ way to initiate a
dialog between two applications.
Following Unix fashion, it’s better from the server side, to register a file name
or a directory name by calling resmgr_attach().
From the client side, you only have to call an open() to obtain a file descriptor
to use read(), write(), but you also can you MsgSendxx() to send specific
messages.
You can see an example in ‘Writing a resource manager’ in the doc.

Unfortunately, unlike name_open() can do (or could do), open() can’t find a name
over a network, YOU have to know where is the ‘name’ to open because it’s a
‘classical’ file name. for example : open("/net/distant_machine/tmp/my_server",
…).

Can NTO use

prefix -A/tmp/my_server=/net/distant_machine/tmp/my_server

as in QNX4 to make “classical” file opens, etc. network enabled?

No “prefix”, the NTO way is:

ln -sP /net/distant_machine/tmp/my_server /tmp/my_server

-xtang

On Fri, 26 Jan 2001 08:43:23 -0800, Bruce Knoth <bknoth@erg.sri.com> wrote:

Any idea on when global message passing will be supported? Should I be looking
at a different technique?

No idea when global message passing will be ready, but in the meantime you can use the
/proc/mount folder to get all you need to connect to a remote server process.

Here are the significant parts of the code (I hope nothing really important is missing):

/**

  • the server should do something like this…
    */

pNameAttach = name_attach (NULL, ATTACH_POINT, NAME_FLAG_ATTACH_GLOBAL);
if (pNameAttach != NULL ) {
bReceiveError = FALSE;
while (bReceiveError == FALSE) {
nRxPid = MsgReceive (pNameAttach->chid, pBenchMsg, nBufSize, &MsgInfo);
if (nRxPid == 0) {
// handle pulses, messages, whatever
// …
// …


/**

  • this is how a client looks like
    */

mhConnectionID = ConnectToServer ();
if (mhConnectionID != INVALID_ID) {
nRet = MsgSend (hConnectionID, m_pBenchMsg, m_nMessageSize, NULL, 0);
// …
//

/**

  • The client locates the NID/PID/CHID by peeking into /proc/mount
  • folder on the remote machine, i.e. if the server machine is my_server
  • and the global name is my_name, then a shell command like
  • ls -la /net/my_server/proc/mount/dev/name/global/my_name
  • will give us enough info to connect to the server process
  • Here is the code to do this:
    */

/**

  • Locate the server process on local or remote node
  • Return connection ID handle. Otherwise,
  • Return error code if server not available
    /
    static int ConnectToServer (void)
    {
    int hFile;
    int hConnectionID;
    int nBytesRead;
    char szPidInfo [256];
    char szRemotePath [256];
    DIR
    dirp;
    struct dirent* direntp;

if (strlen (mOptions.szHostName) > 0) {
// hostname assumed valid → locate server process on remote node
hConnectionID = name_open (ATTACH_POINT, NAME_FLAG_ATTACH_GLOBAL);
if (hConnectionID == INVALID_ID) {
// KLUDGE: overcame global names not implemented in Neutrino
strcpy (szRemotePath, “/net/”);
strcat (szRemotePath, mOptions.szHostName);
strcat (szRemotePath, “/proc/mount/dev/name/global/”);
strcat (szRemotePath, ATTACH_POINT);

dirp = opendir (szRemotePath);
if (dirp != NULL) {
direntp = readdir (dirp);
if (direntp != NULL) {
// extract NIP/PID/CHID from d_name
LocateProcessCoordinates (direntp->d_name);
hConnectionID = ConnectAttach (mOptions.nNodeID, mOptions.nProcessID, mOptions.nChannelID, 0, 0);
}

closedir (dirp);
}
else {
printf (“Error opening directory %s\n”, szRemotePath);
}
}
}
else {
// hostname missing → locate server process on local node
hConnectionID = name_open (ATTACH_POINT, NAME_FLAG_ATTACH_GLOBAL);
if (hConnectionID == INVALID_ID) {
printf (“local name open failed\n”);
perror (“errno”);
}
}

return hConnectionID;
}


/**

  • LocateProcessCoordinates
  • parse the input string to extract the NID/PID/CHID
  • input string has these values separated by commas, e.g.
  • szInfo = 0,12345,1,2,12 means:
  • nodeId = 0, pid=12345, chid=1, handle=2, ftype=12 (_FTYPE_NAME)
  • set also the remote node ID as seen from the local node
    */
    static void LocateProcessCoordinates (char *pszInfo)
    {
    int ndx;
    int nValue [3];
    char *pszThis;
    char *pszNext;
    char szValue [32];
    char szFullHostName [50];

ndx = 0;
memset (&nValue [0], 0, sizeof (nValue));
pszThis = pszInfo;
pszNext = strpbrk (pszThis, “,”);
while (ndx < 3 && pszNext != NULL) {
memset (szValue, 0, sizeof (szValue));
strncpy (szValue, pszThis, pszNext - pszThis);
nValue [ndx] = atoi (szValue);

pszThis = pszNext + 1;
pszNext = strpbrk (pszThis, “,”);
++ndx;
}

mOptions.nProcessID = nValue [1];
mOptions.nChannelID = nValue [2];

strcpy (szFullHostName, “/net/”);
strcat (szFullHostName, mOptions.szHostName);
mOptions.nNodeID = netmgr_strtond (szFullHostName, NULL);

/* here is the info needed to do a ConnectAttach */
printf (“NID/PID/CHID = %d/%d/%d\n”, mOptions.nNodeID, mOptions.nProcessID, mOptions.nChannelID);
}