PACS System 0.1.0
PACS DICOM system library
Loading...
Searching...
No Matches
socket_handle Class Reference

RAII wrapper for platform socket handle. More...

Collaboration diagram for socket_handle:
Collaboration graph

Public Types

using native_type = int
 

Public Member Functions

 socket_handle ()=default
 
 socket_handle (native_type fd)
 
 ~socket_handle ()
 
 socket_handle (const socket_handle &)=delete
 
socket_handleoperator= (const socket_handle &)=delete
 
 socket_handle (socket_handle &&other) noexcept
 
socket_handleoperator= (socket_handle &&other) noexcept
 
bool valid () const noexcept
 
native_type get () const noexcept
 
void close () noexcept
 

Static Public Attributes

static constexpr native_type invalid_value = -1
 

Private Attributes

native_type fd_ {invalid_value}
 

Detailed Description

RAII wrapper for platform socket handle.

Definition at line 460 of file ai_service_connector.cpp.

Member Typedef Documentation

◆ native_type

Definition at line 466 of file ai_service_connector.cpp.

Constructor & Destructor Documentation

◆ socket_handle() [1/4]

socket_handle::socket_handle ( )
default

◆ socket_handle() [2/4]

socket_handle::socket_handle ( native_type fd)
inlineexplicit

Definition at line 471 of file ai_service_connector.cpp.

471: fd_(fd) {}

◆ ~socket_handle()

socket_handle::~socket_handle ( )
inline

Definition at line 472 of file ai_service_connector.cpp.

472{ close(); }
void close() noexcept

◆ socket_handle() [3/4]

socket_handle::socket_handle ( const socket_handle & )
delete

◆ socket_handle() [4/4]

socket_handle::socket_handle ( socket_handle && other)
inlinenoexcept

Definition at line 477 of file ai_service_connector.cpp.

477 : fd_(other.fd_) {
478 other.fd_ = invalid_value;
479 }
static constexpr native_type invalid_value

Member Function Documentation

◆ close()

void socket_handle::close ( )
inlinenoexcept

Definition at line 493 of file ai_service_connector.cpp.

493 {
494 if (fd_ != invalid_value) {
495#ifdef _WIN32
496 closesocket(fd_);
497#else
498 ::close(fd_);
499#endif
501 }
502 }

◆ get()

native_type socket_handle::get ( ) const
inlinenodiscardnoexcept

Definition at line 491 of file ai_service_connector.cpp.

491{ return fd_; }

◆ operator=() [1/2]

socket_handle & socket_handle::operator= ( const socket_handle & )
delete

◆ operator=() [2/2]

socket_handle & socket_handle::operator= ( socket_handle && other)
inlinenoexcept

Definition at line 481 of file ai_service_connector.cpp.

481 {
482 if (this != &other) {
483 close();
484 fd_ = other.fd_;
485 other.fd_ = invalid_value;
486 }
487 return *this;
488 }

◆ valid()

bool socket_handle::valid ( ) const
inlinenodiscardnoexcept

Definition at line 490 of file ai_service_connector.cpp.

490{ return fd_ != invalid_value; }

Member Data Documentation

◆ fd_

native_type socket_handle::fd_ {invalid_value}
private

Definition at line 505 of file ai_service_connector.cpp.

◆ invalid_value

native_type socket_handle::invalid_value = -1
staticconstexpr

Definition at line 467 of file ai_service_connector.cpp.


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