Open Lighting Architecture  Latest Git
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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 ()
int Release ()
 Release the file descriptor. More...

Constructor & Destructor Documentation

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

Create a new SocketCloser.

fdthe file descriptor to close.

Member Function Documentation

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

Release the file descriptor.

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

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

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