25#include "XrdVersion.hh"
31#include "XrdSec/XrdSecInterface.hh"
35# include <sys/socket.h>
47#define URLTAG "["<<fUrl.Host<<":"<<fUrl.Port<<"]"
65 if (url && !
Init(url, fd)) {
66 TRACE(XERR,
"severe error occurred while"
67 " opening a connection" <<
" to server "<<
URLTAG);
77 XPDLOC(ALL,
"PhyConn::Init")
84 if (
fUser.length() <= 0) {
87 struct passwd *pw = getpwuid(getuid());
91 DWORD length =
sizeof (lname);
92 ::GetUserName(lname, &length);
99 char *hn = XrdSysDNS::getHostName(((
fUrl.
Host.length() > 0) ?
112 struct servent *sent = getservbyname(
"proofd",
"tcp");
114 TRACE(XERR,
"service 'proofd' not found by getservbyname" <<
115 ": using default IANA assigned tcp port 1093");
121 TRACE(XERR,
"getservbyname found tcp port " <<
fPort <<
122 " for service 'proofd'");
139 XPDLOC(ALL,
"PhyConn::Connect")
141 int maxTry = -1, timeWait = -1;
159 TRACE(DBG,
"new logical connection ID: "<<logid);
163 if (
fLastErr == kXR_NotAuthorized) {
167 msg.erase(msg.rfind(
":"));
168 TRACE(XERR,
"authentication failure: " << msg);
177 TRACE(DBG,
"access to server granted.");
183 TRACE(DBG,
"disconnecting");
187 TRACE(DBG,
"connection attempt failed: sleep " << timeWait <<
" secs");
191 Sleep(timeWait * 1000);
202 XPDLOC(ALL,
"PhyConn::TryConnect")
204 const char *ctype[2] = {
"UNIX",
"TCP"};
210 bool isUnix = (
fTcp) ? 0 : 1;
211#if ROOTXRDVERS <= ROOT_PhyConnNoReuse
213 TRACE(XERR,
"Reusing an existing connection (descriptor "<<fd<<
214 ") not supported by the xroot client version (requires xrootd >= 3.0.3)");
286 XPDLOC(ALL,
"PhyConn::GetAccessToSrv")
304 TRACE(XERR,
"handshake failed with server "<<
URLTAG);
311 TRACE(XERR,
"server at "<<
URLTAG<<
" is unknown : protocol error");
318 TRACE(XERR,
"client already logged-in at "<<
URLTAG<<
" (!): protocol error!");
#define TRACE(Flag, Args)
R__EXTERN C unsigned int sleep(unsigned int seconds)
#define NAME_CONNECTTIMEOUT
#define NAME_FIRSTCONNECTMAXCNT
int(* XrdProofConnSender_t)(const char *, int, void *)
int ReadRaw(void *buffer, int BufferLength, int substreamid=-1, int *usedsubstreamid=0)
int WriteRaw(const void *buffer, int BufferLength, int substreamid=0)
ERemoteServerType fServerType
XrdClientMessage * ReadMessage(int streamid)
bool Connect(XrdClientUrlInfo RemoteHost, bool isUnix=0)
XrdClientAbsUnsolMsgHandler * UnsolicitedMsgHandler
void TakeUrl(XrdOucString url)
ESrvType DoHandShake(XrdClientPhyConnection *p=0)
Performs initial hand-shake with the server in order to understand which kind of server is there at t...
static void GetRetryParam(int &maxtry, int &timewait)
Retrieve current values of the retry control parameters, numer of retries and wait time between attem...
XrdClientPhyConnection * fPhyConn
friend class XrdProofPhyConn
XrdClientAbsUnsolMsgHandler * fUnsolMsgHandler
bool Login()
This method perform the loggin-in into the server just after the hand-shake.
XrdClientMessage * ReadMsg()
Pickup message from the queue.
bool Init(const char *url, int fd=-1)
Initialization.
void Connect(int fd=-1)
Run the connection attempts: the result is stored in fConnected.
int TryConnect(int fd=-1)
Connect to remote server.
int ReadRaw(void *buf, int len, XrdClientPhyConnection *=0)
Low level write call.
void Close(const char *opt="")
Close the connection.
void SetAsync(XrdClientAbsUnsolMsgHandler *uh, XrdProofConnSender_t=0, void *=0)
Set handler of unsolicited responses.
int WriteRaw(const void *buf, int len, XrdClientPhyConnection *=0)
Low level write call.
bool GetAccessToSrv(XrdClientPhyConnection *=0)
Gets access to the connected server.