added accessors for some members

This commit is contained in:
Bob Polis 2020-04-24 16:13:55 +02:00
parent 027f9cb59e
commit db6b0cca5e

View File

@ -20,10 +20,8 @@ using namespace sc::io;
socketstream::socketstream(int domain, int type)
: fdstream(), _domain(domain), _type(type) {
_socket = socket(_domain, _type, 0);
this->socket(::socket(_domain, _type, 0));
throw_if_min1_msg(_socket, "could not create socket");
_inbuf.fd(_socket);
_outbuf.fd(_socket);
std::memset(&_sa, 0, sizeof(struct sockaddr_storage));
}
@ -31,8 +29,8 @@ socketstream::socketstream() : fdstream() {
std::memset(&_sa, 0, sizeof(struct sockaddr_storage));
}
socketstream::socketstream(socketstream&& other) {
_socket = other._socket;
socketstream::socketstream(socketstream&& other) : fdstream(other._socket) {
this->socket(other._socket);
_domain = other._domain;
_type = other._type;
std::memcpy(&_sa, &other._sa, sizeof(struct sockaddr_storage));
@ -43,7 +41,7 @@ socketstream::socketstream(socketstream&& other) {
socketstream& socketstream::operator=(socketstream&& other) {
if (this != &other) {
_socket = other._socket;
this->socket(other._socket);
_domain = other._domain;
_type = other._type;
std::memcpy(&_sa, &other._sa, sizeof(struct sockaddr_storage));
@ -105,6 +103,8 @@ void socketstream::make_server(const socket_address& sa) {
peer._socket = active_socket;
peer._domain = _domain;
peer._type = _type;
peer._inbuf.fd(active_socket);
peer._outbuf.fd(active_socket);
return peer;
}
@ -188,3 +188,9 @@ socket_address socketstream::address_from_endpoint(const struct sockaddr* endpoi
}
return sa;
}
void socketstream::socket(int sock) {
_socket = sock;
ifd(sock);
ofd(sock);
}