RPC Problem

RPC Problem

Post by Sean Klingl » Tue, 11 Apr 1995 04:00:00

I'm having a problem getting clnttcp_create() to work in the SVR4
arena.  I can get it to work fine on AIX, but on Motorola SVR4 and
Solaris the fucntion doesn't appear to work.  It doesn't matter if I
pass a bad IP address or a bad socket (I'd expect to get a not
connected error here), the function always does the same thing.  It
even does the same thing when I pass good arguments (what works on

On Motorola:
rpctcp_create: Bad file number RPC: Remote system error - Bad file number

On Solaris:
rpctcp_create: Error 0 RPC: Remote system error - Error 0

Works like a champ!

So, my question is, does this function work in SVR4?  Is it obsolete?
Am I just completely missing something I should be doing?

When I use the clnt_create() function instead, my client works like a
champ on both platforms. (Unfortunately, I need to control the socket
myself before connect time so that I can force a bind to the proper
source address, so clnt_create() is not enough)

Here is my client program (just a small test program to get the date
from another host -- I already have a server running there)

#include <stdio.h>
#include <errno.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <rpc/rpc.h>
#ifdef SVR4
#include <rpc/clnt_soc.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <ctype.h>
#include "date.h"

** prog server_addr bind_addr
** (if bind address is not specified, no bind will occur)
main( argc, argv )
int     argc;
char    *argv[];
CLIENT      *client_sp;
int         client_sock;
int         destport;
char        *server_p;
long        *lresult_p;
struct sockaddr_in sockaddr_s;
struct sockaddr_in destaddr_s;
char        **sresult_p;
int         zero = 0;

if( argc >= 2 )
    server_p = argv[ 1 ];

    if( 0 > ( client_sock = socket( AF_INET, SOCK_STREAM, 0 ) ) )
        printf( "Error opening the socket (%d)\n", errno );
        exit( 0 );

    memset( ( char * )&destaddr_s, 0, sizeof( destaddr_s ) );
    destaddr_s.sin_addr.s_addr = inet_addr( argv[ 1 ] );
    destaddr_s.sin_port = 0;
    destaddr_s.sin_family = AF_INET;
    destport = pmap_getport( &destaddr_s, DATE_PROG, DATE_VERS,
        IPPROTO_TCP );
    if( !destport )
        printf( "no server running at %s\n",
                        inet_ntoa( destaddr_s.sin_addr ) );
        exit( 0 );
printf( "destination port returned = %d\n", destport );
    destaddr_s.sin_port = htons( destport );

    if( argc > 2 )
        sockaddr_s.sin_addr.s_addr = inet_addr( argv[ 2 ] );
        sockaddr_s.sin_family = AF_INET;
        sockaddr_s.sin_port = INADDR_ANY;
        sockaddr_s.sin_port = htons( destport );

        printf( "binding to %s (%s)\n", argv[ 2 ],
            inet_ntoa( sockaddr_s.sin_addr ) );

        if( bind( client_sock, ( struct sockaddr * )&sockaddr_s,
            sizeof( sockaddr_s ) ) < 0 )
            printf( "Error in the bind! (%d)\n", errno );
            exit( 0 );

    if( connect( client_sock, ( struct sockaddr * )&destaddr_s,
        sizeof( destaddr_s ) ) < 0 )
        printf( "connect failed (%d) -- %s\n", errno,
            inet_ntoa( destaddr_s.sin_addr ) );
        exit( 0 );

printf( "connecting to %s\n", inet_ntoa( destaddr_s.sin_addr ) );
    client_sp = clnttcp_create( &destaddr_s, DATE_PROG, DATE_VERS,
        &client_sock, 0, 0 );
    if( client_sp )
        /* rpc calls deleted, I never get this far on SVR4 anyway */
        clnt_destroy( client_sp );
        printf( "error in creation (%d)\n", errno );
        clnt_pcreateerror( server_p );

    close( client_sock );
    fprintf( stderr, "usage: %s IP_address [bind_IP_address]\n", argv[ 0 ] );




1. Need help/advice with rpc problem

        Hi! I'm having problems with my server and
am not sure what files to look at for misconfigurations..
I'm hoping that someone out there might see these
error messages as obvious signposts to fix some file
I can mount nsf filesystems from other workstations
in the lab, but cannot seem to mount news or accoess
the oed2 server.. I've gotten the following errors:

Dec  9 15:46:02 enterprise mountd[11789]: couldn't register TCP MOUNTPROG
Dec  9 15:46:03 enterprise mountd[11790]: couldn't register TCP MOUNTPROG    
Dec  9 15:46:04 enterprise mountd[11791]: couldn't register TCP MOUNTPROG
Dec  9 15:46:06 enterprise mountd[11793]: couldn't register TCP MOUNTPROG
Dec  9 15:46:07 enterprise mountd[11794]: couldn't register TCP MOUNTPROG
Dec  9 15:46:08 enterprise mountd[11795]: couldn't register TCP MOUNTPROG
Dec  9 15:46:09 enterprise mountd[11796]: couldn't register TCP MOUNTPROG  
Dec  9 15:46:11 enterprise mountd[11797]: couldn't register TCP MOUNTPROG
Dec  9 15:46:12 enterprise mountd[11798]: couldn't register TCP MOUNTPROG      
(lots of these)


I've actually been able to mount the filesystem sometimes. I used
the IP address and it is mounted now, but when I try to use news
and actually read a posting, i get NNTP (or some such) not responding.
any clues? please email me with any suggestions :)

2. PCI modem and LINUX

3. RPC problem with Solaris2.4

4. MS Abcess is best...

5. RPC problem with 1.1.59?

6. X86 2.4 showrev -p, Single-user mode

7. Rpc Problem

8. HELP HELP Printing stuffed by SCO patch

9. mount/share/rpc problem

10. RPC problem after installing Disksuite

11. RPC problem

12. NFS portmap RPC problem

13. Sun RPC problem