Article View: comp.client-server
Article #206How to use svc_getcaller((SVCXPRT *) cl)
From: Michael Wagner
Date: Tue, 12 Jan 1993 18:04
Date: Tue, 12 Jan 1993 18:04
61 lines
2485 bytes
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
.......................................................
Technical Details
Message-ID:
<1iv16tINN3jd@paganini.cs.unc.edu>Path:
arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!darwin.sura.net!gatech!concert!borg.cs.unc.edu!not-for-mailShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!darwin.sura.net!gatech!concert!borg.cs.unc.edu!not-for-mail From: wagner@cs.unc.edu (Michael Wagner) Newsgroups: comp.client-server Subject: How to use svc_getcaller((SVCXPRT *) cl) Date: 12 Jan 1993 13:04:13 -0500 Organization: The University of North Carolina at Chapel Hill Lines: 61 Distribution: world Message-ID: <1iv16tINN3jd@paganini.cs.unc.edu> NNTP-Posting-Host: paganini.cs.unc.edu