28#include <netinet/tcp.h>
39 uint16_t subStreamNum,
59 env->
GetInt(
"TimeoutResolution", timeoutResolution );
102 env->
GetInt(
"TCPKeepAlive", keepAlive );
112#if ( defined(__linux__) || defined(__GNU__) ) && defined( TCP_KEEPIDLE ) && \
113 defined( TCP_KEEPINTVL ) && defined( TCP_KEEPCNT )
116 env->
GetInt(
"TCPKeepAliveTime", param );
117 st =
pSocket->SetSockOpt(SOL_TCP, TCP_KEEPIDLE, ¶m,
sizeof(param));
123 env->
GetInt(
"TCPKeepAliveInterval", param );
124 st =
pSocket->SetSockOpt(SOL_TCP, TCP_KEEPINTVL, ¶m,
sizeof(param));
130 env->
GetInt(
"TCPKeepAliveProbes", param );
131 st =
pSocket->SetSockOpt(SOL_TCP, TCP_KEEPCNT, ¶m,
sizeof(param));
201 std::ostringstream o;
217 type =
pSocket->MapEvent( type );
327 socklen_t optSize =
sizeof( errorCode );
605 if( waitSeconds >=0 )
607 time_t resendTime = ::time( 0 ) + waitSeconds;
612 "[%s] Won't retry kXR_endsess request because would"
613 "reach connection timeout.",
626 "will wait for %d seconds before replaying the endsess request",
748 time_t now = time(0);
778 if( !( st =
pSocket->TlsHandShake(
this,
pUrl.GetHostName() ) ).IsOK() )
820 "HS writer object missing!" ) );
855 waitSeconds = rsp->
body.wait.seconds;
864 time_t now = time( 0 );
869 "replay the endsess request.",
pStreamName.c_str() );
887 !
pSockAddr.isMapped() ) ?
"IPv6" :
"IPv4" );
908 return std::string();
union ServerResponse::@040373375333017131300127053271011057331004327334 body
const char * XrdSysE2T(int errcode)
Utility class encapsulating reading hand-shake response logic.
Utility class encapsulating writing hand-shake request logic.
Utility class encapsulating reading response message logic.
Utility class encapsulating writing request logic.
static std::string ToStreamName(const URL &url, uint16_t strmnb)
Convert Stream object and sub-stream number to stream name.
~AsyncSocketHandler()
Destructor.
bool OnReadTimeout() XRD_WARN_UNUSED_RESULT
std::unique_ptr< AsyncHSWriter > hswriter
virtual bool OnConnectionReturn() XRD_WARN_UNUSED_RESULT
bool OnWriteTimeout() XRD_WARN_UNUSED_RESULT
TransportHandler * pTransport
bool OnWrite() XRD_WARN_UNUSED_RESULT
bool OnTimeoutWhileHandshaking() XRD_WARN_UNUSED_RESULT
uint16_t pTimeoutResolution
bool CheckHSWait() XRD_WARN_UNUSED_RESULT
bool EventRead(uint8_t type) XRD_WARN_UNUSED_RESULT
std::unique_ptr< AsyncHSReader > hsreader
XRootDStatus DoTlsHandShake()
void OnFault(XRootDStatus st)
bool HandleHandShake(std::unique_ptr< Message > msg) XRD_WARN_UNUSED_RESULT
bool OnWriteWhileHandshaking() XRD_WARN_UNUSED_RESULT
XRootDStatus Close()
Close the connection.
time_t pConnectionTimeout
void OnFaultWhileHandshaking(XRootDStatus st)
virtual void Event(uint8_t type, XrdCl::Socket *)
Handle a socket event.
kXR_int32 HandleWaitRsp(Message *rsp)
bool HandShakeNextStep(bool done) XRD_WARN_UNUSED_RESULT
bool OnReadWhileHandshaking() XRD_WARN_UNUSED_RESULT
std::unique_ptr< AsyncMsgWriter > reqwriter
XRootDStatus EnableUplink()
Enable uplink.
std::string GetIpStack() const
Get the IP stack.
bool EventWrite(uint8_t type) XRD_WARN_UNUSED_RESULT
std::string GetHostName()
Get hostname.
std::unique_ptr< AsyncMsgReader > rspreader
XRootDStatus DisableUplink()
Disable uplink.
std::unique_ptr< HandShakeData > pHandShakeData
bool OnRead() XRD_WARN_UNUSED_RESULT
XRootDStatus Connect(time_t timeout)
Connect to the currently set address.
bool pTlsHandShakeOngoing
AsyncSocketHandler(const URL &url, Poller *poller, TransportHandler *transport, AnyObject *channelData, uint16_t subStreamNum, Stream *strm)
Constructor.
bool OnTLSHandShake() XRD_WARN_UNUSED_RESULT
time_t pConnectionStarted
bool SendHSMsg() XRD_WARN_UNUSED_RESULT
std::string GetIpAddr()
Get IP address.
void OnHeaderCorruption()
const char * GetBuffer(uint32_t offset=0) const
Get the message buffer.
static Log * GetLog()
Get default log.
static Env * GetEnv()
Get default client environment.
bool GetInt(const std::string &key, int &value)
void Error(uint64_t topic, const char *format,...)
Report an error.
void Info(uint64_t topic, const char *format,...)
Print an info.
void Debug(uint64_t topic, const char *format,...)
Print a debug message.
The message representation used throughout the system.
Interface for socket pollers.
@ ReadTimeOut
Read timeout.
@ ReadyToWrite
Writing won't block.
@ WriteTimeOut
Write timeout.
@ ReadyToRead
New data has arrived.
@ Connected
The socket is connected.
@ Connecting
The connection process is in progress.
Perform the handshake and the authentication for each physical stream.
std::string GetHostId() const
Get the host part of the URL (user:password@host:port)
static const int noPort
Do not add port number.
@ fmtAddr
Address using suitable ipv4 or ipv6 format.
const uint16_t errSocketOptError
const int DefaultTCPKeepAliveProbes
const uint16_t stFatal
Fatal error, it's still an error.
const uint16_t errPollerError
const uint16_t stError
An error occurred that could potentially be retried.
const uint16_t errSocketTimeout
const uint16_t errInternal
Internal error.
const int DefaultTimeoutResolution
const uint64_t AsyncSockMsg
const int DefaultTCPKeepAliveInterval
const int DefaultTCPKeepAlive
const uint16_t errConnectionError
const int DefaultTCPKeepAliveTime
const uint16_t errSocketError
const uint16_t errCorruptedHeader
Data structure that carries the handshake information.
uint16_t code
Error type, or additional hints on what to do.
uint16_t status
Status of the execution.
bool IsOK() const
We're fine.
std::string ToString() const
Create a string representation.