XPRDconnect
XPRDconnect |
Purpose
Synopsis
XPRDmosel XPRDconnect(XPRDcontext ctx, const char *cnstr, XPRDfct_open fmgr, void *fctx, char *errmsg, int msglen);
Arguments
ctx
|
XPRD context
|
cnstr
|
Connection string
|
fmgr
|
File manager routine (can be
NULL)
|
fctx
|
Data pointer to be passed to the
fmgr routine
|
errmsg
|
Buffer to return error messages
|
msglen
|
Size of
errmsg
|
Return value
A Mosel instance or
NULL in case of failure.
Example
In the following example 4 Mosel instances are started:
m1 is started in a separate process on the same host;
m2 is launched using the
xprmsrv server running on host
"myserver";
m3 is executed using the
ssh command on host
"secure", and for
m4, the
xprmsrv server running on host
"mybox" is requested to use the context
"xpress" with password
"mypass":
m1=XPRDconnect(xdctx,"",NULL,NULL,buf1,256); m2=XPRDconnect(xdctx,"myserver",NULL,NULL,buf2,256); m3=XPRDconnect(xdctx,"rcmd:ssh secure mosel -r",NULL,NULL,buf3,256); m4=XPRDconnect(xdctx,"xsrv:mybox/xpress/mypass",NULL,NULL,buf4,256);
Further information
1. An empty connection string
"" is equivalent to
"rcmd:" (instance started on the same machine in a separate process). Any other string not starting by either
"rcmd:",
"xsrv:" or
"xssh:" is interpreted as a host name that is prefixed by
"xsrv:" (instance started on the specified host using the
xprmsrv protocol). Refer to the Mosel Language Reference Manual, section on module
mmjobs for further detail on how to use these drivers.
2. In case of failure, the parameter
errmsg receives the error message reported by the driver used to perform the connection.
3. The optional file manager
fmgr allows to control file access from the created remote instance: all requests for opening files are passed to this routine. Depending on the return value of the function, the request is rejected, processed by a user provided function or handled by the default file manager (
i.e. direct access to physical files). Refer to Section
File managers for further explanation.
4. Function
XPRDstart is automatically called after a successful connection in order to start (if necessary) the
connection manager.
5. Default streams of the newly created instance are initialised with
"null:" for the input (
i.e. stream disabled);
"rmt:sysfd:1" for output and
"rmt:sysfd:2" for errors. These settings can be changed using
XPRDsetdefstream.
Related topics