xrootd
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | Private Member Functions | List of all members
XrdNet Class Reference

#include <XrdNet.hh>

Inheritance diagram for XrdNet:
Inheritance graph
[legend]
Collaboration diagram for XrdNet:
Collaboration graph
[legend]

Public Member Functions

int Accept (XrdNetAddr &myAddr, int opts=0, int timeout=-1)
 
int Accept (XrdNetPeer &myPeer, int opts=0, int timeout=-1)
 
int Bind (int port, const char *contype="tcp")
 
int Bind (char *path, const char *contype="stream")
 
int Connect (XrdNetAddr &myAddr, const char *dest, int port=-1, int opts=0, int timeout=-1)
 
int Connect (XrdNetPeer &myPeer, const char *dest, int port=-1, int opts=0, int timeout=-1)
 
int Port ()
 
int Relay (XrdNetPeer &Peer, const char *dest, int opts=0)
 
int Relay (const char *dest)
 
virtual void Secure (XrdNetSecurity *secp)
 
void setDefaults (int options, int buffsz=0)
 
void setDomain (const char *dname)
 
void Trim (char *hname)
 
void unBind ()
 Unbind the network from any bound resouces.
 
int WSize ()
 
 XrdNet (XrdSysError *erp, XrdNetSecurity *secp=0)
 
virtual ~XrdNet ()
 Destructor.
 

Protected Attributes

XrdSysErroreDest
 
XrdNetSecurityPolice
 
char * Domain
 
int Domlen
 
int iofd
 
int Portnum
 
int PortType
 
int Windowsz
 
int netOpts
 
int BuffSize
 
XrdNetBufferQBuffQ
 

Private Member Functions

int do_Accept_TCP (XrdNetAddr &myAddr, int opts)
 
int do_Accept_TCP (XrdNetPeer &myPeer, int opts)
 
int do_Accept_UDP (XrdNetPeer &myPeer, int opts)
 

Constructor & Destructor Documentation

◆ XrdNet()

XrdNet::XrdNet ( XrdSysError erp,
XrdNetSecurity secp = 0 
)

Constructor

Parameters
erpThe error object for printing error messages. It must be supplied.
secpThe initial NetSecurity object. This secp object must not be deleted nor directly used after the call as this object assumes its ownership and may delete it at any time.

◆ ~XrdNet()

virtual XrdNet::~XrdNet ( )
virtual

Destructor.

Member Function Documentation

◆ Accept() [1/2]

int XrdNet::Accept ( XrdNetAddr myAddr,
int  opts = 0,
int  timeout = -1 
)

Accept incoming TCP connection. This is the preferred method for TCP.

Parameters
myAddrthe address object to contain connection information.
optsprocessing options: XRDNET_DELAY - do not set nodelay on socket. XRDNET_KEEPALIVE - use TCP keep alive on socket. XRDNET_NOCLOSEX - do not allow socket to close on exec() XRDNET_NOEMSG - supress printing error messages XRDNET_NOLINGER - Do not linger when closing socket.
timeoutmaximum seconds to wait for a conection. When negative, the default, no time limit applies.
Returns
!0 Successful connection occurred, myAddr holds information.
=0 Failure, a timeout or permanent error occurred.

◆ Accept() [2/2]

int XrdNet::Accept ( XrdNetPeer myPeer,
int  opts = 0,
int  timeout = -1 
)

Accept incoming TCP or UDP connection. This method should only be used for UDP-style networks. The previous method is preferred for TCP-style networks.

Parameters
myPeerthe peer object to contain connection information.
optsprocessing options: XRDNET_DELAY - TCP: do not set nodelay on socket. XRDNET_KEEPALIVE - TCP: use TCP keep alive on socket. XRDNET_NEWFD - UDP: obtain new file descriptor XRDNET_NOCLOSEX - ALL: keep socket across exec() calls XRDNET_NODNTRIM - ALL: don't trim domain name in myPeer XRDNET_NOEMSG - ALL: supress printing error messages XRDNET_NORLKUP - ALL: avoid doing reverse DNS look-up XRDNET_USETLS - ALL: enable TLS upon connection
timeoutmaximum seconds to wait for a conection. When negative, the default, no time limit applies.
Returns
!0 Successful connection occurred, myPeer holds information.
=0 Failure, a timeout or permanent error occurred.

◆ Bind() [1/2]

int XrdNet::Bind ( char *  path,
const char *  contype = "stream" 
)

Bind a network object to a Unix named socket.

Parameters
paththe file system path to a named socket to bind with.
contypeEither "stream" to use TCP-tyle streaming protocol or "datagram" to use UDP-style messaging.
Returns
0 Successfully bound the port.
!0 Failure, return value is -errno describing the error.

◆ Bind() [2/2]

int XrdNet::Bind ( int  port,
const char *  contype = "tcp" 
)

Bind a network object to a TCP or UDP port number.

Parameters
portthe port number to bind to. Use 0 for arbitrary port.
contypeEither "tcp" for TCP networks or "udp" for UDP networks.
Returns
0 Successfully bound the port.
!0 Failure, return value is -errno describing the error.

◆ Connect() [1/2]

int XrdNet::Connect ( XrdNetAddr myAddr,
const char *  dest,
int  port = -1,
int  opts = 0,
int  timeout = -1 
)

Create a TCP socket and connect it to the given host and port. This is the preferred method for making TCP based connections.

Parameters
myAddraddress object where connection information is returned.
destdestination hostname or IP address.
portthe port number to connect to. If < 0 then the dest param must contain the port number preceeded by a colon.
optsprocessing options: XRDNET_NOCLOSEX - do not allow socket to close on exec() XRDNET_NOEMSG - supress printing error messages XRDNET_NORLKUP - avoid doing reverse DNS look-up
timeoutthe maximum number of seconds to wait for the connection to complete. A negative value waits forever. Values greater than 255 seconds are set to 255.
Returns
true Connection completed, myAddr holds connection information.
false Connection failed.

◆ Connect() [2/2]

int XrdNet::Connect ( XrdNetPeer myPeer,
const char *  dest,
int  port = -1,
int  opts = 0,
int  timeout = -1 
)

Create a TCP or UDP socket and connect it to the given host and port. The previous method is preferred for creating TCP sockets.

Parameters
myPeerpeer object where connection information is returned.
destdestination hostname or IP address.
portthe port number to connect to. If < 0 then the dest param must contain the port number preceeded by a colon.
optsprocessing options: XRDNET_NOCLOSEX - do not allow socket to close on exec() XRDNET_NODNTRIM - do not trim domain name in myPeer. XRDNET_NOEMSG - supress printing error messages XRDNET_NORLKUP - avoid doing reverse DNS look-up XRDNET_UDPSOCKET - create a UDP socket (o/w use TCP).
timeoutthe maximum number of seconds to wait for the connection to complete. A negative value waits forever. Values greater than 255 seconds are set to 255.
Returns
true Connection completed, myPeer holds connection information.
false Connection failed.

◆ do_Accept_TCP() [1/2]

int XrdNet::do_Accept_TCP ( XrdNetAddr myAddr,
int  opts 
)
private

◆ do_Accept_TCP() [2/2]

int XrdNet::do_Accept_TCP ( XrdNetPeer myPeer,
int  opts 
)
private

◆ do_Accept_UDP()

int XrdNet::do_Accept_UDP ( XrdNetPeer myPeer,
int  opts 
)
private

◆ Port()

int XrdNet::Port ( )
inline

Get the port number, if any, bound to this network.

Returns
>0 The bound port number.
<=0 The network is not bound to a port.

References Portnum.

◆ Relay() [1/2]

int XrdNet::Relay ( const char *  dest)

◆ Relay() [2/2]

int XrdNet::Relay ( XrdNetPeer Peer,
const char *  dest,
int  opts = 0 
)

◆ Secure()

virtual void XrdNet::Secure ( XrdNetSecurity secp)
virtual

Add a NetSecurity object to the existing accept() security constraints.

Parameters
secpPointer to the network security object. This object must not be deleted nor directly used after the call as this object assumes its ownership and may delete it at any time.

Reimplemented in XrdInet.

◆ setDefaults()

void XrdNet::setDefaults ( int  options,
int  buffsz = 0 
)
inline

Set network defaults.

Parameters
optionsThe options to be added to Accept(), Bind() and Connect() calls. These options cannot be turned off, so be careful.
buffszThe UDP buffer size (the initial default is 32K) or the TCP window size (initial default is OS dependent).

References netOpts, and Windowsz.

◆ setDomain()

void XrdNet::setDomain ( const char *  dname)
inline

Set network domain name.

Parameters
dnameThe domain name which indicates to Trim() what part of the host name is so common that it can be trimmed.

References Domain, and Domlen.

◆ Trim()

void XrdNet::Trim ( char *  hname)

Trims off the domain name in a host name.

Parameters
hnameThe host name to be trimmed (it is modified).

◆ unBind()

void XrdNet::unBind ( )

Unbind the network from any bound resouces.

◆ WSize()

int XrdNet::WSize ( )

Get the current TCP RCVBUF window size.

Returns
>0 The current window size.
<=0 Either the network is not bound to a port or an error has occurred. Window size is unavailable.

Member Data Documentation

◆ BuffQ

XrdNetBufferQ* XrdNet::BuffQ
protected

◆ BuffSize

int XrdNet::BuffSize
protected

◆ Domain

char* XrdNet::Domain
protected

Referenced by setDomain().

◆ Domlen

int XrdNet::Domlen
protected

Referenced by setDomain().

◆ eDest

XrdSysError* XrdNet::eDest
protected

◆ iofd

int XrdNet::iofd
protected

◆ netOpts

int XrdNet::netOpts
protected

Referenced by setDefaults().

◆ Police

XrdNetSecurity* XrdNet::Police
protected

◆ Portnum

int XrdNet::Portnum
protected

Referenced by Port().

◆ PortType

int XrdNet::PortType
protected

◆ Windowsz

int XrdNet::Windowsz
protected

Referenced by setDefaults().


The documentation for this class was generated from the following file: