Open Lighting Architecture  0.9.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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.
 ~SocketCloser ()
 Destructor.
int Release ()
 Release the file descriptor.

Constructor & Destructor Documentation

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

Create a new SocketCloser.

Parameters
fdthe file descriptor to close.

Member Function Documentation

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 file: