Logo ROOT  
Reference Guide
authclient.C File Reference

Detailed Description

This macro should be run together with authserv.C to test authentication between two remote ROOT sessions.

Run first the authserv.C within a ROOT session on the server machine, eg. "srv.machi.ne":

     root[] .x authserv.C(3000)

authserv accepts as argument the port where it starts listening (default 3000). You can then run authclient.c in a ROOT session on the client machine: root[] .x authclient.C("srv.machi.ne:3000")

and you should get prompted for the credentials, if the case. To start a parallel socket of size, for example, 5, enter the size as second argument, ie

     root[] .x authclient.C("srv.machi.ne:3000",5)
#include "TPSocket.h"
int authclient(const char *host = "up://localhost:3000", int sz = 0)
Int_t par = (sz > 1) ? 1 : 0;
// Parse protocol, if any
TString proto(TUrl(host).GetProtocol());
TString protosave = proto;
// Get rid of authentication suffix
TString asfx = proto;
if (proto.EndsWith("up") || proto.EndsWith("ug")) {
} else if (proto.EndsWith("s") || proto.EndsWith("k") ||
proto.EndsWith("g") || proto.EndsWith("h")) {
// Force parallel (even of size 1)
TString newurl = "p" + asfx;
newurl += "://";
if (strlen(TUrl(host).GetUser())) {
newurl += TUrl(host).GetUser();
newurl += "@";
newurl += TUrl(host).GetHost();
newurl += ":";
newurl += TUrl(host).GetPort();
cout << "authclient: starting a (parallel) authenticated socket at "
<< newurl.Data() << " (size: " << sz << ")" << endl;
// Print out;
if (s)
if (s->IsAuthenticated())
cout << "authclient: auth socket: OK" << endl;
cout << "authclient: auth socket: failed" << endl;
// Cleanup
if (s) {
// Remove this authentication from the token list to avoid
// later warnings
delete s;
int Int_t
Definition: RtypesCore.h:45
const char * proto
Definition: civetweb.c:16604
static TSocket * CreateAuthSocket(const char *user, const char *host, Int_t port, Int_t size=0, Int_t tcpwindowsize=-1, TSocket *s=0, Int_t *err=0)
Creates a socket or a parallel socket and authenticates to the remote server specified in 'url' on re...
Definition: TSocket.cxx:1432
Basic string class.
Definition: TString.h:136
const char * Data() const
Definition: TString.h:369
TString & Remove(Ssiz_t pos)
Definition: TString.h:673
This class represents a WWW compatible URL.
Definition: TUrl.h:33
const char * GetUser() const
Definition: TUrl.h:65
const char * GetHost() const
Definition: TUrl.h:67
Int_t GetPort() const
Definition: TUrl.h:78
static constexpr double s

Definition in file authclient.C.