Open Lighting Architecture  Latest Git
Public Member Functions | List of all members
ola::network::SocketCloser Class Reference

Detailed Description

Automatically close a socket when it goes out of scope.

This class is useful if you need to temporarily open a socket and want to make sure it's cleaned up. Think of it as an auto_ptr for file descriptors.

Public Member Functions

 SocketCloser (int fd)
 Create a new SocketCloser. More...
 
 ~SocketCloser ()
 Destructor.
 
int Release ()
 Release the file descriptor. More...
 

Constructor & Destructor Documentation

◆ SocketCloser()

ola::network::SocketCloser::SocketCloser ( int  fd)
inlineexplicit

Create a new SocketCloser.

Parameters
fdthe file descriptor to close.

Member Function Documentation

◆ Release()

int ola::network::SocketCloser::Release ( )
inline

Release the file descriptor.

Calling Release prevents the file descriptor from being closed when this object goes out of scope.

Returns
the original file descriptor or -1 if the descriptor was already released.

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