DCMTK: OFSockAddr Class Reference

DCMTK Version 3.6.9 OFFIS DICOM Toolkit

Loading...
Searching...
No Matches
Classes | Public Member Functions | Private Attributes | List of all members
OFSockAddr Class Reference

A simple wrapper class for a struct sockaddr_storage object that can be used to store an TCP/IPv4 (struct sockaddr_in) or TCP/IPv6 (struct sockaddr_in6) address. More...

## Classes
union | socket_address

## Public Member Functions
| OFSockAddr ()
| Default constructor.
| ~OFSockAddr ()
| Destructor.
void | clear ()
| initialize address storage object with memset
struct sockaddr * | getSockaddr ()
| access socket address storage object as struct sockaddr (opaque address)
struct sockaddr_in * | getSockaddr_in ()
| access socket address storage object as struct sockaddr_in (IPv4 address)
struct sockaddr_in6 * | getSockaddr_in6 ()
| access socket address storage object as struct sockaddr_in6 (IPv6 address)
const struct sockaddr_in * | getSockaddr_in_const () const
| access socket address storage object as const struct sockaddr_in (IPv4 address)
const struct sockaddr_in6 * | getSockaddr_in6_const () const
| access socket address storage object as const struct sockaddr_in6 (IPv6 address)
socklen_t | size () const
| return size of sockaddr struct depending on current protocol family
short | getFamily () const
| get current protocol family.
void | setFamily (short family)
| set current protocol family.
void | setPort (unsigned short port)
| set port number for current protocol family.

## Private Attributes
socket_address | sa
| container for the socket address structure.

## Detailed Description

A simple wrapper class for a struct sockaddr_storage object that can be used to store an TCP/IPv4 (struct sockaddr_in) or TCP/IPv6 (struct sockaddr_in6) address.

## Class Documentation

## ◆ OFSockAddr::socket_address

union OFSockAddr::socket_address

## Member Function Documentation

## ◆ getFamily()

short OFSockAddr::getFamily | ( |  | ) | const
| inline

get current protocol family.

Returns 0 if uninitialized, AF_INET or AF_INET6 otherwise.

Returns
  current protocol family of the socket address.

References sa.

## ◆ getSockaddr()

struct sockaddr * OFSockAddr::getSockaddr | ( |  | ) |
| inline

access socket address storage object as struct sockaddr (opaque address)

Returns
  address storage object as struct sockaddr *.

References sa.

## ◆ getSockaddr_in()

struct sockaddr_in * OFSockAddr::getSockaddr_in | ( |  | ) |
| inline

access socket address storage object as struct sockaddr_in (IPv4 address)

Returns
  address storage object as struct sockaddr_in *.

References sa.

## ◆ getSockaddr_in6()

struct sockaddr_in6 * OFSockAddr::getSockaddr_in6 | ( |  | ) |
| inline

access socket address storage object as struct sockaddr_in6 (IPv6 address)

Returns
  address storage object as struct sockaddr_in6 *.

References sa.

## ◆ getSockaddr_in6_const()

const struct sockaddr_in6 * OFSockAddr::getSockaddr_in6_const | ( |  | ) | const
| inline

access socket address storage object as const struct sockaddr_in6 (IPv6 address)

Returns
  address storage object as const struct sockaddr_in6 *.

References sa.

## ◆ getSockaddr_in_const()

const struct sockaddr_in * OFSockAddr::getSockaddr_in_const | ( |  | ) | const
| inline

access socket address storage object as const struct sockaddr_in (IPv4 address)

Returns
  address storage object as const struct sockaddr_in *.

References sa.

## ◆ setFamily()

void OFSockAddr::setFamily | ( | short | family | ) |
| inline

set current protocol family.

Parameters

  family | protocol family, should be AF_INET or AF_INET6.

References sa.

## ◆ setPort()

void OFSockAddr::setPort | ( | unsigned short | port | ) |

set port number for current protocol family.

Only works if the family has been set to AF_INET or AF_INET6 prior to calling this method.

Parameters

  port | port number in network byte order (e.g. output of htons()).

## ◆ size()

socklen_t OFSockAddr::size | ( |  | ) | const

return size of sockaddr struct depending on current protocol family

Returns
  size of sockaddr struct depending on current protocol family

## Member Data Documentation

## ◆ sa

socket_address OFSockAddr::sa
| private

container for the socket address structure.

Guaranteed to be large enough for all supported protocol types.

Referenced by clear(), getFamily(), getSockaddr(), getSockaddr_in(), getSockaddr_in6(), getSockaddr_in6_const(), getSockaddr_in_const(), and setFamily().

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

- ofstd/include/dcmtk/ofstd/ofsockad.h

Generated on Sat Mar 1 2025 for DCMTK Version 3.6.9 by Doxygen 1.13.2