Dear all,
at the moment I’m trying to run our LINUX Application on a QNX Host PC. Everything works fine just the rpc-communication hangs up, when a
rpc-request is received and the function svc_getreqset( &readfds ); is called. Normally if this function is called my registered ApplFunc_1 should be entered. But that is not the case (Please have a look to the c-code below)
1.) I start rpc_bind (or portmap which does the same)
2.) I start my application on the QNX-Host PC
3.) When starting the application the function initRPC( ) is called one time. There the function ApplFunc_1( ) will be registered by calling svc_register( ). initRPC() returns with “true”, that means success.
4.) I send a RPC-request via TCP/IP from my WindowsPC to the QNX PC
5.) When calling svc_getreqset( &readfds ); the QNX Application hangs up
This stuff runs on my LINUX platform, so either I forgot something or there is a difference between Linux and QNX. I assume that the fd_set variables are not correct. I have investigated them but I am not shure what has to be the right content, so I cannot say if they are good or bad.
Searching the web and the qnx forums did not deliver a solution for my problems.
I am very happy about a little help from you all.
Tanks and Best Regards
Marc
#include <rpc/rpc.h>
#include <rpc/pmap_clnt.h>
#include <errno.h>
#define MYAPPL ((u_long)400000)
#define MYAPPL_VERS_1 ((u_long)1)
#define MYAPPL_NULL ((u_long)0)
// ApplFunc_1 is the function which should be entered if a rpc-call is received
extern "C"
{
void ApplFunc_1( struct svc_req *rqstp, register SVCXPRT *transp );
};
initRPC()
{
bool retval( false );
register SVCXPRT *transp;
pmap_unset( MYAPPL, MYAPPL_VERS_1 );
// create UDP socket and register it
transp = svcudp_create( RPC_ANYSOCK );
if( transp != NULL )
{
if( svc_register( transp, MYAPPL, MYAPPL_VERS_1, ApplFunc_1, IPPROTO_UDP ) )
{
retval = true;
}
else
{
// to register
}
}
else
{
// cannot create UDP service." << endl;
}
if( retval )
{
// create TCP socket and register it
transp = svctcp_create( RPC_ANYSOCK, 0, 0 );
if( transp != NULL )
{
if( !svc_register( transp, MYAPPL, MYAPPL_VERS_1, ApplFunc_1, IPPROTO_TCP ) )
{
retval = false;
/// unable to register
}
else
{
// register done.
}
}
else
{
retval = false;
// cannot create TCP service.
}
}
return( retval );
};
void execRPC()
{
uint16 dtbsz( getdtablesize() ); // max file descriptor no.
fd_set readfds( svc_fdset ); // file descriptor set for server.
struct timeval timeout = { 0L, 1000L }; // 1ms wait for select.
// check if any requests have arrived.
switch(select( dtbsz, &readfds, NULL, NULL, &timeout ) )
{
case -1: // error
if( errno == EBADFD )
{
// Call of select(..) failed
}
break;
case 0: // no requests available
break;
default: // process requests
[b] // !! IF RPC REQUEST processed DEFAULT is entered, printf is shown, but the !!
// !! function called ApplFunc_1(), which was registered svc_register( ) is not reached and the
// !! complete PROCESS hangs forever.
printf("rpc request received \n");
svc_getreqset( &readfds );[/b] break;
}