🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.client-server
1 messages
1 total messages Started by Michael Wagner Tue, 12 Jan 1993 18:04
How to use svc_getcaller((SVCXPRT *) cl)
#206
Author: Michael Wagner
Date: Tue, 12 Jan 1993 18:04
61 lines
2485 bytes
I am developing an application that is using SUN RPC.
The server may be contacted by many different clients,
and needs to know who they are.  My man page says that
svc_getcaller() is the way to do this:

     struct sockaddr_in * svc_getcaller(xprt)
     SVCXPRT *xprt;

          The approved way of getting the network address of  the
          caller  of  a procedure associated with the RPC service
          transport handle, xprt.


I tried to use svc_getcaller() as follows (for non-C++ programmers,
think of cout << as a print()).  This *doesn't* work.  I always get
the same family, port, and addrs printed out, even when I have
two clients on different machines.  They all look like nonsense
values.  Am I doing something wrong?  Has anyone else gotten
this to work?

/******************************************************************/
struct sockaddr_in old_caller;

	/* .
	   .
	   . */
int
check_caller(CLIENT * cl)
{
        struct sockaddr_in *caller = svc_getcaller((SVCXPRT *) cl);
        cout << "caller: family: " << (unsigned short) caller->sin_family
        							<< "\n";
        cout << "caller: port:   " << caller->sin_port << "\n";
        cout << "caller: addr:   " << (char *) inet_ntoa(caller->sin_addr)
        							<< "\n";
        if ((caller->sin_family == old_caller.sin_family) &&
            (caller->sin_port == old_caller.sin_port) &&
            (caller->sin_addr.s_addr == old_caller.sin_addr.s_addr)) {
                 cout << "callers are the same\n";
                return (1);
        } else {
                cout << "callers are different\n";
                old_caller = *caller;
        }
        return (0);
};
/******************************************************************/

Thanks for any help.

Mike Wagner
wagner@cs.unc.edu



-- 
.......................................................
michael paul wagner
wagner@hatteras.cs.unc.edu		ahlan wa sahlan
.......................................................
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads