Hi,
Is there somewhere some exemples for the fonctions IPC between nodes under
RTP (ConnectAttach, MsgSend*, MsgReveive*, etc.) ?
Any help would be appreciated.
Qingguo
You can view the library reference found at the following address.
http://qdn.qnx.com/support/docs/neutrino_2.11_en/lib_ref/about.html
There is also a lot of information that can be found in the Programmers Guide. This guide can be found at http://qdn.qnx.com/support/docs/neutrino_2.11_en/prog/about.html
Regards,
Dave B.
Qingguo Kou <qingguo@irg.ca> wrote:
Hi,
Is there somewhere some exemples for the fonctions IPC between nodes under
RTP (ConnectAttach, MsgSend*, MsgReveive*, etc.) ?
Any help would be appreciated.
Qingguo
Qingguo Kou <qingguo@irg.ca> wrote:
Thanks for you help.
I think that I didn’t made a clear question. Please let me explain :
I tried to use the functions as ConnectAttach(), MsgSend() to simply send
some messages to a process on an another node. With QNX 4, we used
qnx_name_locate to find the pid of the process who had used priviously
qnx_name_attach. In RTP, I can’t use name_attach and name_open because only
local name is supported. Now to use ConnectAttach, I don’t know how to fill
its arguments like
uint32_t nd,
pid_t pid,
int chid
I would like find some short and clear examples to understand how to use
the functions as ConnectAttach(), MsgSend(), etc. There are in the docs some
such examples for name_attach(), name_open(), MsgReceive, etc. but not for
the functions as ConnectAttach(), MsgSend().
The following is an work arround I’ve posted a while ago, for how to
name_open() global names (for now).
It simply go though nodes under “/net/” and try to find the name you asked.
Once it successed, you can of cause MsgSend() on the fd returned.
On RTP, “finding a server” is always done by resolve the server’s
registed name path, if you still want to use ConnectAttach() directly,
you have several options:
- Have server write it’s “nodname, pid, chid” into a “well known node”'s
“well known” file. like:
/net/serverrecode/var/run/servers
and clients just open that file, netmgr_strtond(nodename) to get nd,
and ConnectAttach() it.
- Instead of the file, you could have a “Service server” which stay in
a “well known” place (/net/servers/dev/services_server), and all client
just connect to it to get services and their associate (nodename, pid, chid)
server.
Here’s the code:
#include <sys/dispatch.h>
#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
#include <share.h>
int global_name_open(const char *name, int flags)
{
int fd;
DIR *dir;
struct dirent *dent;
char *newname;
if ((fd = name_open(name, 0)) != -1 || (flags & NAME_FLAG_ATTACH_GLOBAL) == 0) {
return fd;
}
if ((dir = opendir("/net")) == NULL) {
errno = ENOENT;
return -1;
}
while (dent = readdir(dir)) {
newname = alloca(strlen("/net/") + strlen(dent->d_name) +
strlen("/dev/name/global/") + strlen(name) + 1);
if (!newname) {
errno = ENOMEM;
return -1;
}
sprintf(newname, “/net/%s/dev/name/global/%s”, dent->d_name, name);
fd = _connect(_NTO_SIDE_CHANNEL, newname, 0, O_RDWR, SH_DENYNO,
_IO_CONNECT_OPEN, 1, _IO_FLAG_RD | _IO_FLAG_WR,
_FTYPE_NAME, 0, 0, 0, 0, 0, 0);
if (fd != -1) {
closedir(dir);
return fd;
}
}
closedir(dir);
errno = ENOENT;
return -1;
}
-xtang
Thanks for you help.
I think that I didn’t made a clear question. Please let me explain :
I tried to use the functions as ConnectAttach(), MsgSend() to simply send
some messages to a process on an another node. With QNX 4, we used
qnx_name_locate to find the pid of the process who had used priviously
qnx_name_attach. In RTP, I can’t use name_attach and name_open because only
local name is supported. Now to use ConnectAttach, I don’t know how to fill
its arguments like
uint32_t nd,
pid_t pid,
int chid
I would like find some short and clear examples to understand how to use
the functions as ConnectAttach(), MsgSend(), etc. There are in the docs some
such examples for name_attach(), name_open(), MsgReceive, etc. but not for
the functions as ConnectAttach(), MsgSend().
Best regards.
Qingguo K
“Applications Mail Group” <apps@qnx.com> a écrit dans le message news:
9kc5fq$dua$1@nntp.qnx.com…
You can view the library reference found at the following address.
http://qdn.qnx.com/support/docs/neutrino_2.11_en/lib_ref/about.htmlThere is also a lot of information that can be found in the Programmers
Guide. This guide can be found at
http://qdn.qnx.com/support/docs/neutrino_2.11_en/prog/about.html
Regards,
Dave B.
Qingguo Kou <> qingguo@irg.ca> > wrote:
Hi,
Is there somewhere some exemples for the fonctions IPC between nodes
under
RTP (ConnectAttach, MsgSend*, MsgReveive*, etc.) ?
Any help would be appreciated.
Qingguo