/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* Server.cpp :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: iherman- 65535) throw std::runtime_error("Invalid port"); if (password_.empty()) throw std::runtime_error("Empty password"); serverSocket_ = socket(AF_INET, SOCK_STREAM, 0); if (serverSocket_ < 0) throw std::runtime_error("Failed to create socket"); struct sockaddr_in addr; std::memset(&addr, 0, sizeof(addr)); addr.sin_family = AF_INET; addr.sin_port = htons(port_); addr.sin_addr.s_addr = INADDR_ANY; bind(serverSocket_, (struct sockaddr*)&addr, sizeof(addr)); std::cout << "Server port: " << port_ << "\nServer Password: " << password_ << std::endl; } Server::~Server() { close(serverSocket_); } Server &Server::operator=(const Server& other) { if (this != &other) { port_ = other.port_; serverSocket_ = other.serverSocket_; password_ = other.password_; } return *this; }