LibreOffice
LibreOffice 24.2 SDK C/C++ API Reference
Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
osl::SocketAddr Class Reference

The class should be understood as a reference to a socket address handle (struct sockaddr). More...

#include <socket_decl.hxx>

Public Member Functions

 SocketAddr ()
 Creates socket address of unknown type. More...
 
 SocketAddr (const SocketAddr &Addr)
 Copy constructor. More...
 
 SocketAddr (const oslSocketAddr Addr, __osl_socket_NoCopy nocopy)
 The SocketAddr takes over the responsibility of the handle (which means that the handle gets destructed by the destructor of this reference) More...
 
 SocketAddr (oslSocketAddr Addr)
 Copyconstructs the oslSocketAddr handle. More...
 
 SocketAddr (const ::rtl::OUString &strAddrOrHostName, sal_Int32 nPort)
 TCP/IP-specific constructor. More...
 
 ~SocketAddr ()
 destroys underlying oslSocketAddress More...
 
bool is () const
 Checks if the SocketAddr was created successful. More...
 
inline ::rtl::OUString getHostname (oslSocketResult *pResult=NULL) const
 Converts the address to a (human readable) domain-name. More...
 
bool setHostname (const ::rtl::OUString &sDottedIpOrHostname)
 Sets the IP address or hostname of the SocketAddress. More...
 
sal_Int32 getPort () const
 Returns the port number of the address. More...
 
bool setPort (sal_Int32 nPort)
 Sets the port number of the address. More...
 
bool setAddr (const ::rtl::ByteSequence &address)
 Sets the address of the underlying socket address struct in network byte order. More...
 
inline ::rtl::ByteSequence getAddr (oslSocketResult *pResult=NULL) const
 Returns the address of the underlying socket in network byte order. More...
 
SocketAddroperator= (oslSocketAddr Addr)
 assign the handle to this reference. More...
 
SocketAddroperator= (const SocketAddr &Addr)
 
SocketAddrassign (oslSocketAddr Addr, __osl_socket_NoCopy nocopy)
 Assigns the socket addr without copyconstructing it. More...
 
bool operator== (oslSocketAddr Addr) const
 Returns true if the underlying handle is identical to the Addr handle. More...
 
bool operator== (const SocketAddr &Addr) const
 Returns true if the underlying handle is identical to the Addr handle. More...
 
oslSocketAddr getHandle () const
 Returns the underlying SocketAddr handle without copyconstructing it. More...
 

Static Public Member Functions

static inline ::rtl::OUString getLocalHostname (oslSocketResult *pResult=NULL)
 Get the hostname for the local interface. More...
 
static void resolveHostname (const ::rtl::OUString &strHostName, SocketAddr &Addr)
 Tries to find an address for a host. More...
 
static sal_Int32 getServicePort (const ::rtl::OUString &strServiceName, const ::rtl::OUString &strProtocolName=::rtl::OUString("tcp"))
 Tries to find the port associated with the given service/protocol- pair (e.g. More...
 

Protected Attributes

oslSocketAddr m_handle
 

Detailed Description

The class should be understood as a reference to a socket address handle (struct sockaddr).

The handle is mutable.

Constructor & Destructor Documentation

◆ SocketAddr() [1/5]

osl::SocketAddr::SocketAddr ( )
inline

Creates socket address of unknown type.

◆ SocketAddr() [2/5]

osl::SocketAddr::SocketAddr ( const SocketAddr Addr)
inline

Copy constructor.

◆ SocketAddr() [3/5]

osl::SocketAddr::SocketAddr ( const oslSocketAddr  Addr,
__osl_socket_NoCopy  nocopy 
)
inline

The SocketAddr takes over the responsibility of the handle (which means that the handle gets destructed by the destructor of this reference)

Parameters
Addra handle
nocopyuse SAL_NO_COPY

◆ SocketAddr() [4/5]

osl::SocketAddr::SocketAddr ( oslSocketAddr  Addr)
inline

Copyconstructs the oslSocketAddr handle.

Parameters
Addra handle

◆ SocketAddr() [5/5]

osl::SocketAddr::SocketAddr ( const ::rtl::OUString strAddrOrHostName,
sal_Int32  nPort 
)
inline

TCP/IP-specific constructor.

Parameters
strAddrOrHostNamestrAddrOrHostName hostname or dotted ip-number of the network interface, the socket shall be created on.
nPorttcp-ip port number

◆ ~SocketAddr()

osl::SocketAddr::~SocketAddr ( )
inline

destroys underlying oslSocketAddress

Member Function Documentation

◆ assign()

SocketAddr & osl::SocketAddr::assign ( oslSocketAddr  Addr,
__osl_socket_NoCopy  nocopy 
)
inline

Assigns the socket addr without copyconstructing it.

Parameters
Addrthe socket address.
nocopyuse SAL_NO_COPY

◆ getAddr()

rtl::ByteSequence osl::SocketAddr::getAddr ( oslSocketResult pResult = NULL) const
inline

Returns the address of the underlying socket in network byte order.

◆ getHandle()

oslSocketAddr osl::SocketAddr::getHandle ( ) const
inline

Returns the underlying SocketAddr handle without copyconstructing it.

◆ getHostname()

rtl::OUString osl::SocketAddr::getHostname ( oslSocketResult pResult = NULL) const
inline

Converts the address to a (human readable) domain-name.

Parameters
[out]pResultvalue of 0 if you are not interested in errors, otherwise *pResult contains an error code on failure or osl_Socket_Ok on success
Returns
the hostname of this SocketAddr or an empty string on failure.
See also
osl_getHostnameOfSocketAddr

◆ getLocalHostname()

rtl::OUString osl::SocketAddr::getLocalHostname ( oslSocketResult pResult = NULL)
inlinestatic

Get the hostname for the local interface.

Parameters
pResultafter the call *pResult contains osl_Socket_Ok on success or an error on failure.
Returns
the hostname

◆ getPort()

sal_Int32 osl::SocketAddr::getPort ( ) const
inline

Returns the port number of the address.

Returns
the port in host-byte order or OSL_INVALID_PORT on errors.

◆ getServicePort()

sal_Int32 osl::SocketAddr::getServicePort ( const ::rtl::OUString strServiceName,
const ::rtl::OUString strProtocolName = ::rtl::OUString("tcp") 
)
inlinestatic

Tries to find the port associated with the given service/protocol- pair (e.g.

"ftp"/"tcp").

Returns
the port number in host-byte order or OSL_INVALID_PORT if no service/protocol pair could be found.

◆ is()

bool osl::SocketAddr::is ( ) const
inline

Checks if the SocketAddr was created successful.

Return values
trueif there is a valid underlying handle
falseno valid underlying handle

◆ operator=() [1/2]

SocketAddr & osl::SocketAddr::operator= ( oslSocketAddr  Addr)
inline

assign the handle to this reference.

The previous handle is released.

◆ operator=() [2/2]

SocketAddr & osl::SocketAddr::operator= ( const SocketAddr Addr)
inline

◆ operator==() [1/2]

bool osl::SocketAddr::operator== ( oslSocketAddr  Addr) const
inline

Returns true if the underlying handle is identical to the Addr handle.

◆ operator==() [2/2]

bool osl::SocketAddr::operator== ( const SocketAddr Addr) const
inline

Returns true if the underlying handle is identical to the Addr handle.

◆ resolveHostname()

void osl::SocketAddr::resolveHostname ( const ::rtl::OUString strHostName,
SocketAddr Addr 
)
inlinestatic

Tries to find an address for a host.

See also
osl_resolveHostname()
Parameters
strHostNamehostname
AddrA newly created socket-address or 0 if the name could not be found.

◆ setAddr()

bool osl::SocketAddr::setAddr ( const ::rtl::ByteSequence address)
inline

Sets the address of the underlying socket address struct in network byte order.

Return values
truesuccess
falsefailure

◆ setHostname()

bool osl::SocketAddr::setHostname ( const ::rtl::OUString sDottedIpOrHostname)
inline

Sets the IP address or hostname of the SocketAddress.

Parameters
[in]sDottedIpOrHostnameIP address or hostname
Return values
truesuccess
falsefailure

◆ setPort()

bool osl::SocketAddr::setPort ( sal_Int32  nPort)
inline

Sets the port number of the address.

Parameters
[in]nPortport number
Return values
truesuccess
falsefailure

Member Data Documentation

◆ m_handle

oslSocketAddr osl::SocketAddr::m_handle
protected

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