|
XRootD
|
A network socket. More...
#include <XrdClSocket.hh>
Collaboration diagram for XrdCl::Socket:Public Types | |
| enum | SocketStatus { Disconnected = 1 , Connected = 2 , Connecting = 3 } |
| Status of the socket. More... | |
Public Member Functions | |
| Socket (int socket=-1, SocketStatus status=Disconnected) | |
| virtual | ~Socket () |
| Desctuctor. | |
| void | Close () |
| Disconnect. | |
| XRootDStatus | Connect (const std::string &host, uint16_t port, uint16_t timout=10) |
| XRootDStatus | ConnectToAddress (const XrdNetAddr &addr, uint16_t timout=10) |
| XRootDStatus | Cork () |
| XRootDStatus | Flash () |
| const AnyObject * | GetChannelID () const |
| int | GetFD () |
| Get the file descriptor. | |
| XRootDStatus | GetFlags (int &flags) |
| Get the socket flags (man fcntl) | |
| std::string | GetName () const |
| Get the string representation of the socket. | |
| std::string | GetPeerName () const |
| Get the name of the remote peer. | |
| const XrdNetAddr * | GetServerAddress () const |
| Get the server address. | |
| std::string | GetSockName () const |
| Get the name of the socket. | |
| XRootDStatus | GetSockOpt (int level, int optname, void *optval, socklen_t *optlen) |
| Get socket options. | |
| SocketStatus | GetStatus () const |
| Get the socket status. | |
| XRootDStatus | Initialize (int family=AF_INET) |
| Initialize the socket. | |
| bool | IsCorked () const |
| bool | IsEncrypted () |
| uint8_t | MapEvent (uint8_t event) |
| virtual XRootDStatus | Read (char *buffer, size_t size, int &bytesRead) |
| XRootDStatus | ReadRaw (void *buffer, uint32_t size, int32_t timeout, uint32_t &bytesRead) |
| Read raw bytes from the socket. | |
| XRootDStatus | ReadV (iovec *iov, int iocnt, int &bytesRead) |
| virtual XRootDStatus | Send (const char *buffer, size_t size, int &bytesWritten) |
| XRootDStatus | Send (Message &msg, const std::string &strmname) |
| XRootDStatus | Send (XrdSys::KernelBuffer &kbuff, int &bytesWritten) |
| void | SetChannelID (AnyObject *channelID) |
| XRootDStatus | SetFlags (int flags) |
| Set the socket flags (man fcntl) | |
| XRootDStatus | SetSockOpt (int level, int optname, const void *optval, socklen_t optlen) |
| Set socket options. | |
| void | SetStatus (SocketStatus status) |
| Set socket status - do not use unless you know what you're doing. | |
| XRootDStatus | TlsHandShake (AsyncSocketHandler *socketHandler, const std::string &thehost=std::string()) |
| XRootDStatus | Uncork () |
| XRootDStatus | WriteRaw (void *buffer, uint32_t size, int32_t timeout, uint32_t &bytesWritten) |
Static Public Member Functions | |
| static XRootDStatus | ClassifyErrno (int error) |
Protected Member Functions | |
| XRootDStatus | Poll (bool readyForReading, bool readyForWriting, int32_t timeout) |
Protected Attributes | |
| AnyObject * | pChannelID |
| bool | pCorked |
| std::string | pName |
| std::string | pPeerName |
| int | pProtocolFamily |
| std::unique_ptr< XrdNetAddr > | pServerAddr |
| int | pSocket |
| std::string | pSockName |
| SocketStatus | pStatus |
| std::unique_ptr< Tls > | pTls |
A network socket.
Definition at line 42 of file XrdClSocket.hh.
Status of the socket.
| Enumerator | |
|---|---|
| Disconnected | The socket is disconnected. |
| Connected | The socket is connected. |
| Connecting | The connection process is in progress. |
Definition at line 48 of file XrdClSocket.hh.
| XrdCl::Socket::Socket | ( | int | socket = -1, |
| SocketStatus | status = Disconnected ) |
Constructor
| socket | already connected socket if available, -1 otherwise |
| status | status of a socket if available |
Definition at line 44 of file XrdClSocket.cc.
References pChannelID, pCorked, pProtocolFamily, pSocket, and pStatus.
|
virtual |
Desctuctor.
Definition at line 55 of file XrdClSocket.cc.
References Close().
Here is the call graph for this function:
|
static |
Definition at line 692 of file XrdClSocket.cc.
References XrdCl::errInternal, XrdCl::errInvalidArgs, XrdCl::errSocketError, XrdCl::stError, XrdCl::stOK, and XrdCl::suRetry.
Referenced by Read(), ReadV(), Send(), and Send().
Here is the caller graph for this function:| void XrdCl::Socket::Close | ( | ) |
Disconnect.
Definition at line 262 of file XrdClSocket.cc.
References close, Disconnected, pName, pPeerName, pSocket, pSockName, pStatus, and pTls.
Referenced by ~Socket(), ConnectToAddress(), Initialize(), ReadRaw(), and WriteRaw().
Here is the caller graph for this function:| XRootDStatus XrdCl::Socket::Connect | ( | const std::string & | host, |
| uint16_t | port, | ||
| uint16_t | timout = 10 ) |
Connect to the given host name
| host | name of the host to connect to |
| port | port to connect to |
| timout | timeout in seconds, 0 for no timeout handling (may be used for non blocking IO) |
Definition at line 183 of file XrdClSocket.cc.
References Connected, Connecting, ConnectToAddress(), XrdCl::errInvalidOp, XrdCl::Utils::GetHostAddresses(), XrdCl::DefaultEnv::GetLog(), XrdCl::Utils::IPAll, XrdCl::Utils::IPv4, XrdCl::Status::IsOK(), XrdCl::Utils::LogHostAddresses(), XrdCl::PostMasterMsg, pProtocolFamily, pSocket, pStatus, and XrdCl::stError.
Here is the call graph for this function:| XRootDStatus XrdCl::Socket::ConnectToAddress | ( | const XrdNetAddr & | addr, |
| uint16_t | timout = 10 ) |
Connect to the given host address
| addr | address of the host to connect to |
| timout | timeout in seconds, 0 for no timeout handling (may be used for non blocking IO) |
Definition at line 212 of file XrdClSocket.cc.
References Close(), XrdCl::Status::code, XrdNetConnect::Connect(), Connected, Connecting, XrdCl::errInvalidOp, XrdCl::Status::errNo, XrdCl::errSocketError, XrdCl::errSocketTimeout, pServerAddr, pSocket, pStatus, pTls, and XrdCl::stError.
Referenced by Connect().
Here is the call graph for this function:
Here is the caller graph for this function:| XRootDStatus XrdCl::Socket::Cork | ( | ) |
Definition at line 782 of file XrdClSocket.cc.
References XrdCl::errSocketOptError, IPPROTO_TCP, pCorked, pSocket, and XrdCl::stFatal.
Referenced by Flash().
Here is the caller graph for this function:| XRootDStatus XrdCl::Socket::Flash | ( | ) |
Definition at line 818 of file XrdClSocket.cc.
References Cork(), XrdCl::Status::IsOK(), and Uncork().
Here is the call graph for this function:
|
inline |
Get Channel ID (an object that allows to identify all sockets corresponding to the same channel)
Definition at line 255 of file XrdClSocket.hh.
References pChannelID.
|
inline |
Get the file descriptor.
Definition at line 214 of file XrdClSocket.hh.
References pSocket.
Referenced by XrdCl::PollerBuiltIn::AddSocket(), and XrdCl::PollerBuiltIn::Start().
Here is the caller graph for this function:| XRootDStatus XrdCl::Socket::GetFlags | ( | int & | flags | ) |
Get the socket flags (man fcntl)
Definition at line 137 of file XrdClSocket.cc.
References XrdCl::errInvalidOp, XrdCl::errSocketError, fcntl(), pSocket, and XrdCl::stError.
Here is the call graph for this function:| std::string XrdCl::Socket::GetName | ( | ) | const |
Get the string representation of the socket.
Definition at line 672 of file XrdClSocket.cc.
References Connected, GetPeerName(), GetSockName(), pName, and pStatus.
Referenced by XrdCl::PollerBuiltIn::AddSocket(), XrdCl::PollerBuiltIn::EnableReadNotification(), XrdCl::PollerBuiltIn::EnableWriteNotification(), XrdCl::PollerBuiltIn::RemoveSocket(), and XrdCl::PollerBuiltIn::Stop().
Here is the call graph for this function:
Here is the caller graph for this function:| std::string XrdCl::Socket::GetPeerName | ( | ) | const |
Get the name of the remote peer.
Definition at line 652 of file XrdClSocket.cc.
References Connected, XrdNetUtils::IPFormat(), pPeerName, pSocket, and pStatus.
Referenced by GetName().
Here is the call graph for this function:
Here is the caller graph for this function:
|
inline |
| std::string XrdCl::Socket::GetSockName | ( | ) | const |
Get the name of the socket.
Definition at line 632 of file XrdClSocket.cc.
References Connected, XrdNetUtils::IPFormat(), pSocket, pSockName, and pStatus.
Referenced by GetName().
Here is the call graph for this function:
Here is the caller graph for this function:| XRootDStatus XrdCl::Socket::GetSockOpt | ( | int | level, |
| int | optname, | ||
| void * | optval, | ||
| socklen_t * | optlen ) |
Get socket options.
Definition at line 152 of file XrdClSocket.cc.
References XrdCl::errInvalidOp, XrdCl::errSocketOptError, pSocket, and XrdCl::stError.
|
inline |
Get the socket status.
Definition at line 125 of file XrdClSocket.hh.
References pStatus.
Referenced by XrdCl::PollerBuiltIn::AddSocket().
Here is the caller graph for this function:| XRootDStatus XrdCl::Socket::Initialize | ( | int | family = AF_INET | ) |
Initialize the socket.
Definition at line 63 of file XrdClSocket.cc.
References Close(), XrdCl::DefaultNoDelay, XrdCl::errFcntl, XrdCl::errInvalidOp, XrdCl::errSocketError, fcntl(), XrdCl::DefaultEnv::GetEnv(), XrdCl::Env::GetInt(), IPPROTO_TCP, XrdCl::Status::IsOK(), pProtocolFamily, pSocket, SetSockOpt(), and XrdCl::stError.
Here is the call graph for this function:
|
inline |
| bool XrdCl::Socket::IsEncrypted | ( | ) |
Definition at line 867 of file XrdClSocket.cc.
References pTls.
Referenced by XrdCl::XRootDMsgHandler::WriteMessageBody().
Here is the caller graph for this function:| uint8_t XrdCl::Socket::MapEvent | ( | uint8_t | event | ) |
Definition at line 835 of file XrdClSocket.cc.
References pTls.
|
protected |
Poll the socket to see whether it is ready for IO
| readyForReading | poll for readiness to read |
| readyForWriting | poll for readiness to write |
| timeout | timeout in seconds, -1 to wait indefinitely |
Definition at line 541 of file XrdClSocket.cc.
References Connected, XrdCl::errInvalidOp, XrdCl::errPoll, XrdCl::errSocketDisconnected, XrdCl::errSocketError, XrdCl::errSocketTimeout, pSocket, pStatus, XrdCl::stError, and XrdCl::stOK.
Referenced by ReadRaw(), and WriteRaw().
Here is the caller graph for this function:
|
virtual |
Read helper for raw socket
| buffer | : the sink for the data |
| size | : size of the sink |
| bytesRead | : number of bytes actually written into the sink |
Definition at line 740 of file XrdClSocket.cc.
References ClassifyErrno(), XrdCl::errSocketError, pSocket, pTls, read, and XrdCl::stError.
Referenced by XrdCl::XRootDTransport::GetBody(), XrdCl::XRootDTransport::GetHeader(), XrdCl::XRootDTransport::GetMore(), and XrdCl::AsyncRawReaderIntfc::ReadBytesAsync().
Here is the call graph for this function:
Here is the caller graph for this function:| XRootDStatus XrdCl::Socket::ReadRaw | ( | void * | buffer, |
| uint32_t | size, | ||
| int32_t | timeout, | ||
| uint32_t & | bytesRead ) |
Read raw bytes from the socket.
Read raw bytes from the socket
| buffer | data to be sent |
| size | size of the data buffer |
| timeout | timout value in seconds, -1 to wait indefinitely |
| bytesRead | the amount of data actually read |
Definition at line 280 of file XrdClSocket.cc.
References Close(), Connected, XrdCl::errInvalidOp, XrdCl::errSocketDisconnected, XrdCl::errSocketError, XrdCl::errSocketTimeout, Poll(), pSocket, pStatus, read, XrdCl::Status::status, XrdCl::stError, and XrdCl::stOK.
Here is the call graph for this function:| XRootDStatus XrdCl::Socket::ReadV | ( | iovec * | iov, |
| int | iocnt, | ||
| int & | bytesRead ) |
ReadV helper for raw socket
| iov | : the buffers for the data |
| iocnt | : number of buffers |
| bytesRead | : number of bytes actually written into the sink |
Definition at line 761 of file XrdClSocket.cc.
References ClassifyErrno(), XrdCl::errSocketError, pSocket, pTls, readv, and XrdCl::stError.
Referenced by XrdCl::AsyncPageReader::Read().
Here is the call graph for this function:
Here is the caller graph for this function:
|
virtual |
Portable wrapper around SIGPIPE free send
| buffer | : data to be written |
| size | : size of the data buffer |
| bytesWritten | : the amount of data actually written |
Definition at line 461 of file XrdClSocket.cc.
References ClassifyErrno(), pSocket, pTls, and write.
Referenced by Send(), and XrdCl::XRootDMsgHandler::WriteMessageBody().
Here is the call graph for this function:
Here is the caller graph for this function:| XRootDStatus XrdCl::Socket::Send | ( | Message & | msg, |
| const std::string & | strmname ) |
Write message to the socket
| msg | : message (request) to be sent |
| strmname | : stream name (for logging purposes) |
Definition at line 503 of file XrdClSocket.cc.
References XrdCl::Buffer::AdvanceCursor(), XrdCl::AsyncSockMsg, XrdCl::Status::code, XrdCl::Log::Dump(), XrdCl::Buffer::GetBufferAtCursor(), XrdCl::Buffer::GetCursor(), XrdCl::DefaultEnv::GetLog(), XrdCl::Message::GetObfuscatedDescription(), XrdCl::Buffer::GetSize(), XrdCl::Status::IsOK(), Send(), XrdCl::Buffer::SetCursor(), and XrdCl::suRetry.
Here is the call graph for this function:| XRootDStatus XrdCl::Socket::Send | ( | XrdSys::KernelBuffer & | kbuff, |
| int & | bytesWritten ) |
Write data from a kernel buffer to the socket
| kbuff | : data to be written |
| bytesWritten | : the amount of data actually written |
Write data from a kernel buffer to the socket
| kbuff | : data to be written |
Definition at line 487 of file XrdClSocket.cc.
References ClassifyErrno(), XrdCl::errNotSupported, pSocket, pTls, XrdSys::Send(), and XrdCl::stError.
Here is the call graph for this function:
|
inline |
Set Channel ID (an object that allows to identify all sockets corresponding to the same channel)
Definition at line 246 of file XrdClSocket.hh.
References pChannelID.
| XRootDStatus XrdCl::Socket::SetFlags | ( | int | flags | ) |
Set the socket flags (man fcntl)
Definition at line 123 of file XrdClSocket.cc.
References XrdCl::errInvalidOp, XrdCl::errSocketError, fcntl(), pSocket, and XrdCl::stError.
Here is the call graph for this function:| XRootDStatus XrdCl::Socket::SetSockOpt | ( | int | level, |
| int | optname, | ||
| const void * | optval, | ||
| socklen_t | optlen ) |
Set socket options.
Definition at line 167 of file XrdClSocket.cc.
References XrdCl::errInvalidOp, XrdCl::errSocketOptError, pSocket, and XrdCl::stError.
Referenced by Initialize().
Here is the caller graph for this function:
|
inline |
Set socket status - do not use unless you know what you're doing.
Definition at line 133 of file XrdClSocket.hh.
References pStatus.
| XRootDStatus XrdCl::Socket::TlsHandShake | ( | AsyncSocketHandler * | socketHandler, |
| const std::string & | thehost = std::string() ) |
Definition at line 844 of file XrdClSocket.cc.
References XrdCl::errInvalidOp, XrdCl::errTlsError, pServerAddr, pTls, XrdCl::stError, and XrdCl::stFatal.
| XRootDStatus XrdCl::Socket::Uncork | ( | ) |
Definition at line 800 of file XrdClSocket.cc.
References XrdCl::errSocketOptError, IPPROTO_TCP, pCorked, pSocket, and XrdCl::stFatal.
Referenced by Flash().
Here is the caller graph for this function:| XRootDStatus XrdCl::Socket::WriteRaw | ( | void * | buffer, |
| uint32_t | size, | ||
| int32_t | timeout, | ||
| uint32_t & | bytesWritten ) |
Write raw bytes to the socket
| buffer | data to be written |
| size | size of the data buffer |
| timeout | timeout value in seconds, -1 to wait indefinitely |
| bytesWritten | the amount of data actually written |
Definition at line 375 of file XrdClSocket.cc.
References Close(), Connected, XrdCl::errInvalidOp, XrdCl::errSocketError, XrdCl::errSocketTimeout, Poll(), pSocket, pStatus, XrdCl::Status::status, XrdCl::stError, XrdCl::stOK, and write.
Here is the call graph for this function:
|
protected |
Definition at line 334 of file XrdClSocket.hh.
Referenced by Socket(), GetChannelID(), and SetChannelID().
|
protected |
Definition at line 335 of file XrdClSocket.hh.
Referenced by Socket(), Cork(), IsCorked(), and Uncork().
|
mutableprotected |
Definition at line 332 of file XrdClSocket.hh.
|
mutableprotected |
Definition at line 331 of file XrdClSocket.hh.
Referenced by Close(), and GetPeerName().
|
protected |
Definition at line 333 of file XrdClSocket.hh.
Referenced by Socket(), Connect(), and Initialize().
|
protected |
Definition at line 329 of file XrdClSocket.hh.
Referenced by ConnectToAddress(), GetServerAddress(), and TlsHandShake().
|
protected |
Definition at line 327 of file XrdClSocket.hh.
Referenced by Socket(), Close(), Connect(), ConnectToAddress(), Cork(), GetFD(), GetFlags(), GetPeerName(), GetSockName(), GetSockOpt(), Initialize(), Poll(), Read(), ReadRaw(), ReadV(), Send(), Send(), SetFlags(), SetSockOpt(), Uncork(), and WriteRaw().
|
mutableprotected |
Definition at line 330 of file XrdClSocket.hh.
Referenced by Close(), and GetSockName().
|
protected |
Definition at line 328 of file XrdClSocket.hh.
Referenced by Socket(), Close(), Connect(), ConnectToAddress(), GetName(), GetPeerName(), GetSockName(), GetStatus(), Poll(), ReadRaw(), SetStatus(), and WriteRaw().
|
protected |
Definition at line 337 of file XrdClSocket.hh.
Referenced by Close(), ConnectToAddress(), IsEncrypted(), MapEvent(), Read(), ReadV(), Send(), Send(), and TlsHandShake().