DCMTK Version 3.7.0 OFFIS DICOM Toolkit

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) More...
struct sockaddr_in * | getSockaddr_in ()
| access socket address storage object as struct sockaddr_in (IPv4 address) More...
struct sockaddr_in6 * | getSockaddr_in6 ()
| access socket address storage object as struct sockaddr_in6 (IPv6 address) More...
const struct sockaddr_in * | getSockaddr_in_const () const
| access socket address storage object as const struct sockaddr_in (IPv4 address) More...
const struct sockaddr_in6 * | getSockaddr_in6_const () const
| access socket address storage object as const struct sockaddr_in6 (IPv6 address) More...
socklen_t | size () const
| return size of sockaddr struct depending on current protocol family More...
short | getFamily () const
| get current protocol family. More...
void | setFamily (short family)
| set current protocol family. More...
void | setPort (unsigned short port)
| set port number for current protocol family. More...

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

## 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.

## ◆ getSockaddr()

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

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

Returns
  address storage object as struct sockaddr *.

## ◆ 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 *.

## ◆ 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 *.

## ◆ 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 *.

## ◆ 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 *.

## ◆ setFamily()

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

set current protocol family.

Parameters

  family | protocol family, should be AF_INET or AF_INET6.

## ◆ 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.

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

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

Generated on Mon Dec 15 2025 for DCMTK Version 3.7.0 by Doxygen 1.9.1