Operating System - OpenVMS
1760470 Members
3203 Online
108894 Solutions
New Discussion юеВ

Re: C++ and system routines

 
SOLVED
Go to solution
Lai King Leung
Occasional Advisor

C++ and system routines

HI

I keep getting an incompatibility error when I try to use any of AST system routines :

&ClientConnectAST,
.......................^
%CXX-E-INCOMPATIBLEPRM, argument of type "void (CSocketClient::*)()" is incompatible with parameter of type "void (*)(...) C"

The sys$qio C prototype is defined as follows:

int sys$qio (unsigned int efn, unsigned short int chan, unsigned int func, struct IOSB_T *iosb, void (*astadr)(__unknown_params), __int64 astprm, void *p1, __int64 p2,
__int64 p3, __int64 p4, __int64 p5, __int64 p6);

I have a class called CSocketClient and a member function called void CSocketClient::ClientConnectAST() which submits the QIO as follows:

status = sys$qio( 0,
TCPChannel,
(IO$_SETMODE|IO$M_CTRL|IO$M_STARTUP),
&connect_iosb,
&ClientConnectAST,
0,
0,
&ecb_dsc,
0,0,0,0);

My question is how do I get the above QIO to execute my member function ClientConnectAST !

I have tried passing the member function as a pointer to the call but I still get the same error. The only work around I could get working was to declare ClientConnectAST as a static method, but the problem with that is I lose all the memeber data unless I declare all the objects global - yuk !

Please can anyone help ?? I need to use AST a lot in my programmes for timers as well.

Thank-you for any help in advance.
4 REPLIES 4
Antoniov.
Honored Contributor

Re: C++ and system routines

Hi Lai,
I read my old C & VAX documentation; i think it is not changed the list parameters.
QIO system service require:
1) efn (event flag): you supply 0, it's right;
2) chan (I/O channel): you supply TCPChannel, it's right;
3) func (function code). you supply SETMODE with M_CTRL and M_STARTUP; ok i don't know the meaning for TCP/IP but SETMODE (that's active AST attention) require AST address to param P1 and I think M_CRTL is simila to M_CRTLCAST of TT driver.
4) iosb (I/O status block): you supply connect_iosb and i think it's right.
5) astadr (AST mask address): you supply ClientConnectAST and you declare it's a C/C++ function. But this is incorrect because you have supply a address of a mask of bits for activate AST (read documentation for format of this parameter). This is wrong!
6) astprm (AST parameter): I never used this, you supply 0, it's Ok.
7) P1 (parameter 1): you supply null but this parameter have to pointer to a your AST C/C++ function (I think ClientConnectAST).
8) P2 (parameter 2) devending by function: read documentation.
9) P3 etc, etc, read and read again your documentation.
This is a few notice I can help you.
Post the result a pay fee assign some points.
Bye
Antoniov
Antonio Maria Vigliotti
Craig A Berry
Honored Contributor

Re: C++ and system routines

Look in SYS$COMMON:[SYSHLP.EXAMPLES.TCPIP] for some C examples. You might also have a look at the Mozilla sources -- there may be some relevant C++ examples in there.

When do you want the AST routine to be called? If you want it to fire as soon as the set-up I/O completes, then you have it in the correct location in your arg list. If you want want it to fire whenever the CTRL or STARTUP events take place, then I think Antoniov's comment #5 is correct.

I'm not that familiar with C++, but a static routine sounds like exactly what you'd need. An AST could complete anytime your program is running, regardless of what's in or out of scope at the moment.
Craig A Berry
Honored Contributor
Solution

Re: C++ and system routines

The following two URLs have examples that should give you everything you need (though they don't deal with sockets specifically). The second one has a title of "[DEC C++] Discussion on Using Member Functions of a Class as ASTs" and shows three different ways of doing what you want.

http://h18000.www1.hp.com/support/asktima/appl_tools/CHAMP_SRC941115001693.html

http://h18000.www1.hp.com/support/asktima/appl_tools/CHAMP_SRC950410005022.html
labadie_1
Honored Contributor

Re: C++ and system routines

Instead of using QIO based code, why wouldn't you use the C socket functions such as at the following pointer


[TCP/IP] Example-C++ World Wide Web HTML file reader.

available at
(url may wrap)

http://h18000.www1.hp.com/support/asktima/communications/009E66D8-5F3A29A0-1C0096.html

Hoping this can help.