Thread: RPC clnt_create fails with RPC_UNKNOWNPROTO error.

  1. #1
    Registered User
    Join Date
    Jan 2012
    Posts
    59

    RPC clnt_create fails with RPC_UNKNOWNPROTO error.

    When I run this (under Cygwin):
    Code:
    #include <stdio.h>#include <stdlib.h>
    #include "rap.h"
    #include <rpc/rpc.h>
    
    
        clnt = clnt_create("s4c",300456,1,"TCP");
        if(clnt==NULL) printf("Client is\tNULL\n");
        if(clnt!=NULL) printf("Client is\tCREATED\n");
    
    
        if(rpc_createerr.cf_stat==RPC_INTR) printf("RPC_INTR\n");
        if(rpc_createerr.cf_stat==RPC_N2AXLATEFAILURE) printf("RPC_N2AXLATEFAILURE\n");
        if(rpc_createerr.cf_stat==RPC_SYSTEMERROR) printf("RPC_SYSTEMERROR\n");
        if(rpc_createerr.cf_stat==RPC_UNKNOWNHOST) printf("RPC_UNKNOWNHOST\n");
        if(rpc_createerr.cf_stat==RPC_UNKNOWNPROTO) printf("RPC_UNKNOWNPROTO\n");
    it comes back:

    Client is NULL
    RPC_UNKNOWNPROTO

    I've tried:
    clnt = clnt_create("s4c",300456,1,"TCP");
    clnt = clnt_create("s4c",300456,1,"TCP");
    clnt = clnt_create("192.168.2.1",300456,1,"tcp");
    clnt = clnt_create("192.168.2.1",300456,1,"tcp");

    I have confirmed that both the client and server machines are running tcp/ip.

    Is "tcp" not the right protocol in Cygwin?
    I know with SUN ONC it's actually ​ONCRPC_TCP.

  2. #2
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    Did you try running Cygwin as administrator?
    The ping command requires administrator rights; maybe so does this.

    Note: The source code uses "tcp".

    Tim S.
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

  3. #3
    Registered User
    Join Date
    Jan 2012
    Posts
    59
    I'm actually not running it in Cygwin. I'm linking it as a .exe and copying it and whatever .dlls it asks for to a Windows7 computer that is networked with a Unix based robot controller.
    I tried running it in the cygwin console but cygwin does not recognize it as executable.
    I ran Distinct's RPCINFO (demo) and it saw programs number 300456 and 300457 so I know the RPC server side functions.
    I would try Cygwin's Mingw libs but only one Cygwin library defines the clnt_create function and it's NOT in any of the Mingw libs.

    I know I'm in over my head but I'm the only one I know who is remotely close to figuring this out.
    Basically I'm trying to create a function that can execute a Unix RPC call and pass the data to a win32 64bit CAD system.

  4. #4
    Registered User
    Join Date
    Nov 2010
    Location
    Long Beach, CA
    Posts
    5,909
    As Tim suggested, it may be a case issue. "tcp" and "TCP" are different. Read the man pages. I'm not sure what RPC library you're using (your other thread had a link to AIX's version), or how the versions may differ, but here's the Linux man page: clnt_create(3) - Linux man page. Read through and look at some of the error function, particularly the perror one, which should print a fairly descriptive message as to what is wrong, so you have something more than "it's broken" to work with.

  5. #5
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    I grep more info from tirpc library source and found it uses "/etc/netconfig". This config file mentions "inet".
    You might make sure the inet libraries/clients/servers are installed in Cygwin.

    What was in my "/etc/netconfig"

    Code:
    #
    # The network configuration file. This file is currently only used in
    # conjunction with the TI-RPC code in the libtirpc library.
    #
    # Entries consist of:
    #
    #       <network_id> <semantics> <flags> <protofamily> <protoname> \
    #               <device> <nametoaddr_libs>
    #
    # The <device> and <nametoaddr_libs> fields are always empty in this
    # implementation.
    #
    udp        tpi_clts      v     inet     udp     -       -
    tcp        tpi_cots_ord  v     inet     tcp     -       -
    udp6       tpi_clts      v     inet6    udp     -       -
    tcp6       tpi_cots_ord  v     inet6    tcp     -       -
    rawip      tpi_raw       -     inet      -      -       -
    local      tpi_cots_ord  -     loopback  -      -       -
    unix       tpi_cots_ord  -     loopback  -      -       -
    Note: I have never knowingly used external networking under Cygwin; so, I think the above is the default information.

    Tim S.
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

  6. #6
    Registered User
    Join Date
    Jan 2012
    Posts
    59
    I tried the upper/lower case thing. It didn't work.
    I am using the Cygwin tirpc/rpc library.
    My "/etc/netconfig" is exactly the same as Tim's.
    Sorry about the AIX confusion. I only reference it for explanations of the functions as Cygwin does not seem to have very good documentation OR a descent forum.


  7. #7
    Registered User
    Join Date
    Nov 2010
    Location
    Long Beach, CA
    Posts
    5,909
    From the PDF documentation http://nfsv4.bullopensource.org/doc/tirpc_rpcbind.php:
    Documentation of the TIRPC API:
    - That does not exist.
    - The TIRPC API supplies the same routines than SunRPC, but with some arguments using new structures.
    Wow, that's pretty crappy. "We don't have documentation, but it's kinda like this thing, just different in some ways that I wont tell you about". Can you use a different library/implementation? Preferably one that doesn't suck and has decent documentation.

    Have you tried any of the error functions as I suggested? Read the man page I provided you, clnt_pcreateerror is used for reporting errors from clnt_create. What error(s) do they report? They might give more detail or a better description of the problem.

  8. #8
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    Did you make sure you have the CygWin's "inet" stuff installed?

    Tim S.
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

  9. #9
    Registered User
    Join Date
    Jan 2012
    Posts
    59
    I'll try clnt_pcreateerror. Do you know of any libraries (other than cygwin or MS services for Unix) that define the clnt_create function? Libc is supposed to but I still get "no clnt_create" errors when I add it to my list of libraries.

    I can ping the RPC server (robot contrller) from the cygwin console, so they both can communicate using tcp but I'll double check ("eyes on") for the inet stuff.

    At this point i am trying to compile/link via the cygwin console but prolific use of IDEs (code blocks/VS 2010) have made me somewhat ignorant of the finer points of the command line interface.

  10. #10
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    Is your computer using IPv4 or IPv6?

    I would guess IPv6 requires "tcp6".

    Tim S.
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

  11. #11
    Registered User
    Join Date
    Nov 2010
    Location
    Long Beach, CA
    Posts
    5,909
    Quote Originally Posted by [email protected] View Post
    I'll try clnt_pcreateerror. Do you know of any libraries (other than cygwin or MS services for Unix) that define the clnt_create function? Libc is supposed to but I still get "no clnt_create" errors when I add it to my list of libraries.
    Don't know of any libraries, short of the default one in Linux, which is glibc (the g being for GNU).

    At this point i am trying to compile/link via the cygwin console but prolific use of IDEs (code blocks/VS 2010) have made me somewhat ignorant of the finer points of the command line interface.
    I've never used Cygwin, and have only heard of people having problems developing with it. With good, free virtualization software around, why don't you just set up a Linux VM and use that? There are way more tutorials and resources for Linux than there are for Cygwin.

    Quote Originally Posted by [email protected] View Post
    I can ping the RPC server (robot contrller) from the cygwin console, so they both can communicate using tcp but I'll double check ("eyes on") for the inet stuff.
    That is not a valid test. ping uses ICMP, which is different from both TCP and UDP (it's actually at the internet layer, same as the "IP" in TCP/IP). Your RPC server is set up to listen on a TCP port, but ICMP doesn't know/care about that stuff. A result from ping means simply that the name or IP address you used refers to a computer that is alive and running the ping service. A better test is to telnet to the TCP port you're trying to talk to, and see if something is listening. If it is listening on that port, it will look something like:
    Code:
    $ telnet google.com 80
    Trying 74.125.113.147...
    Connected to google.com.
    Escape character is '^]'.
    if it's not listening, you may get an immediate reply like "Unable to connect to remote host: Connection refused" or a long delay followed by something like "host can not be reached", meaning there is no computer at that location or there is a firewall that is sending your packets into a black hole, making it look like nobody's there.

    EDIT: Fixed erroneous remark about listening on a port (see red text). Transcript is from a valid listening port.
    Last edited by anduril462; 02-02-2012 at 04:39 PM.

  12. #12
    Registered User
    Join Date
    Jan 2012
    Posts
    59
    So I get the "Unable to connect to remote host: Connection refused". I think the problem here is no Telnet service on the robot?

    The firewall is shut down and they CAN communicate with each other via NFS and FTP.


  13. #13
    Registered User
    Join Date
    Nov 2010
    Location
    Long Beach, CA
    Posts
    5,909
    Can I get a transcript of your command session (copy paste into code tags) to see exactly what telnet command you used and how you tested NFS and FTP? Also, look into the nmap program if Cygwin provides it. It will tell you what ports are open and have something listening on them. According to Wikipedia, it looks like it should be port 111.

  14. #14
    Registered User
    Join Date
    Jan 2012
    Posts
    59
    IPv4 (forgot to answer that one)
    Transcripts are not going to be that easy:
    I have a 3rd party NFS server (NFSAxe) and FTP server (Serv-U) running on the PC (at different times) so the PC acts as the file server. So since I can copy files, delete files and manipulate directories on the PC using the "teach pendant" on the robot I figure TCP communications is working.

    As for the Telnet session I just entered:
    telnet 192.168.1.2

    And it immediately responded:
    Unable to connect to remote host: Connection refused



  15. #15
    Registered User
    Join Date
    Nov 2010
    Location
    Long Beach, CA
    Posts
    5,909
    Quote Originally Posted by [email protected] View Post
    IPv4 (forgot to answer that one)
    Transcripts are not going to be that easy:
    I have a 3rd party NFS server (NFSAxe) and FTP server (Serv-U) running on the PC (at different times) so the PC acts as the file server. So since I can copy files, delete files and manipulate directories on the PC using the "teach pendant" on the robot I figure TCP communications is working.
    Fair enough. Not sure what Windows NFS and FTP servers say about Cygwin networking, but that's okay.

    As for the Telnet session I just entered:
    telnet 192.168.1.2

    And it immediately responded:
    Unable to connect to remote host: Connection refused
    You didn't specify a port, thus it tried the default telnet port of 23. Try "telnet 192.168.1.2 111" to check the default RPC server port of 111.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 15
    Last Post: 01-24-2012, 05:41 PM
  2. Replies: 7
    Last Post: 08-22-2011, 02:44 PM
  3. Replies: 10
    Last Post: 09-24-2010, 01:09 AM
  4. Why this fails?
    By manav in forum C++ Programming
    Replies: 13
    Last Post: 05-29-2008, 01:11 PM
  5. WriteFile() fails and returns strange error
    By Gerread in forum Windows Programming
    Replies: 7
    Last Post: 11-27-2007, 05:02 AM

Tags for this Thread