View topic - XDR routines in QNX 4.25

XDR routines in QNX 4.25

For the old QNX2 and QNX4 RTOS

XDR routines in QNX 4.25

Postby tomoreilly » Mon Jul 28, 2008 7:25 pm

I'm a newcomer to QNX 4.25. I'm having difficulty using the XDR routines. In particular, I create a XDR "memory stream" using xdrmem_create(), but as soon as I attempt to access it with xdr_getpos() I get a segmentation violation. The QNX 4 "knowledge base" at qnx.com mentions a similar problem, and says that XDR programs must be compiled with -Wc,-ei so I am using this flag. Nonetheless the following "simple" program gives segmentation fault when I run it. Any advice would be much appreciated.

#include <stdio.h>
#include <rpc/xdr.h>
#include <netinet/in.h>

int main(int argc, char **argv) {

// Allocate XDR state buffer - allocate lots of extra
unsigned int outBufSize = 1000;

char *outBuf = (char *)malloc(outBufSize);

XDR xdrStream;
xdrmem_create(&xdrStream, outBuf, outBufSize, XDR_ENCODE);

fprintf(stderr, "TEST xdr_getpos()\n");
int pos = xdr_getpos(&xdrStream); // Seg fault occurs here!!!
fprintf(stderr, "xdr_getpos() OK\n");


fprintf(stderr, "TEST xdr_setpos()\n");
if (!xdr_setpos(&xdrStream, 0)) {
fprintf(stderr, "xdr_setpos() failed!\n");
}
else {
fprintf(stderr, "xdr_setpos() OK\n");
}

return 0;
}


Regards,
Tom
tomoreilly
New Member
 
Posts: 3
Joined: Mon Jul 28, 2008 7:13 pm

RE: XDR routines in QNX 4.25

Postby mario » Mon Jul 28, 2008 8:56 pm

Answered in your other post.
mario
QNX Master
 
Posts: 4132
Joined: Sun Sep 01, 2002 1:04 am


Return to QNX2 and QNX4

Who is online

Users browsing this forum: No registered users and 1 guest