added close() to socketstream
This commit is contained in:
@ -149,6 +149,8 @@ namespace sc {
|
|||||||
|
|
||||||
// cleanup: socketstream is RAII class for open socket
|
// cleanup: socketstream is RAII class for open socket
|
||||||
virtual ~socketstream();
|
virtual ~socketstream();
|
||||||
|
bool is_open() { return _iobuf.fd() != -1; }
|
||||||
|
void close();
|
||||||
|
|
||||||
// server
|
// server
|
||||||
void make_server(const socket_address& sa);
|
void make_server(const socket_address& sa);
|
||||||
|
@ -53,8 +53,13 @@ socketstream& socketstream::operator=(socketstream&& other) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
socketstream::~socketstream() {
|
socketstream::~socketstream() {
|
||||||
|
close();
|
||||||
|
}
|
||||||
|
|
||||||
|
void socketstream::close() {
|
||||||
if (_iobuf.fd() != -1) {
|
if (_iobuf.fd() != -1) {
|
||||||
::close(_iobuf.fd());
|
::close(_iobuf.fd());
|
||||||
|
_iobuf.fd(-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user