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