Sponge
CS144's user-space TCP library
|
A handle on a kernel file descriptor. More...
Public Member Functions | |
FDWrapper (const int fd) | |
Construct from a file descriptor number returned by the kernel. More... | |
~FDWrapper () | |
Closes the file descriptor upon destruction. More... | |
void | close () |
Calls close(2) on FDWrapper::_fd. More... | |
An FDWrapper cannot be copied or moved | |
FDWrapper (const FDWrapper &other)=delete | |
FDWrapper & | operator= (const FDWrapper &other)=delete |
FDWrapper (FDWrapper &&other)=delete | |
FDWrapper & | operator= (FDWrapper &&other)=delete |
Public Attributes | |
bool | _closed = false |
Flag indicating whether FDWrapper::_fd has been closed. More... | |
bool | _eof = false |
Flag indicating whether FDWrapper::_fd is at EOF. More... | |
int | _fd |
The file descriptor number returned by the kernel. More... | |
unsigned | _read_count = 0 |
The number of times FDWrapper::_fd has been read. More... | |
unsigned | _write_count = 0 |
The numberof times FDWrapper::_fd has been written. More... | |
A handle on a kernel file descriptor.
FileDescriptor objects contain a std::shared_ptr to a FDWrapper.
Definition at line 15 of file file_descriptor.hh.
|
explicit |
Construct from a file descriptor number returned by the kernel.
[in] | fd | is the file descriptor number returned by open(2) or similar |
Definition at line 15 of file file_descriptor.cc.
FileDescriptor::FDWrapper::~FDWrapper | ( | ) |
Closes the file descriptor upon destruction.
Definition at line 26 of file file_descriptor.cc.
|
delete |
|
delete |
void FileDescriptor::FDWrapper::close | ( | ) |
Calls close(2) on FDWrapper::_fd.
Definition at line 21 of file file_descriptor.cc.
bool FileDescriptor::FDWrapper::_closed = false |
Flag indicating whether FDWrapper::_fd has been closed.
Definition at line 19 of file file_descriptor.hh.
bool FileDescriptor::FDWrapper::_eof = false |
Flag indicating whether FDWrapper::_fd is at EOF.
Definition at line 18 of file file_descriptor.hh.
int FileDescriptor::FDWrapper::_fd |
The file descriptor number returned by the kernel.
Definition at line 17 of file file_descriptor.hh.
unsigned FileDescriptor::FDWrapper::_read_count = 0 |
The number of times FDWrapper::_fd has been read.
Definition at line 20 of file file_descriptor.hh.
unsigned FileDescriptor::FDWrapper::_write_count = 0 |
The numberof times FDWrapper::_fd has been written.
Definition at line 21 of file file_descriptor.hh.