void Socket::socket_listen(){ int success = listen(this->fd, MAXLEN_CONNECTION_QUEUE); if (success != OK){ std::stringstream file_desc; file_desc << this->fd; std::string error_desc(MSG_ERROR_LISTEN); error_desc.append(MSG_FD); error_desc.append(file_desc.str()); throw SystemError(error_desc, __FILE__, __LINE__); } }
int main(void) { struct settings cfg = {true, true}; uint32_t result = network_main(cfg, PORT, TIMEOUT); int line = result >> 16; int error = (result >> 8) & 0xff; int code = result & 0xff; if (code != E_OK) { printf("%s, errno=%d, line=%d\n", error_desc(code), error, line); return EXIT_FAILURE; } return EXIT_SUCCESS; }
void Socket::socket_bind(){ try{ int success = bind(this->fd, this->sckt_info.addr->ai_addr, this->sckt_info.addr->ai_addrlen); if (success != OK){ std::stringstream file_desc; file_desc << this->fd; std::string error_desc(MSG_ERROR_BIND); error_desc.append(MSG_FD); error_desc.append(file_desc.str()); throw SystemError(error_desc, __FILE__, __LINE__); } }catch(std::exception &e){ std::string error_desc = MSG_ERROR_BIND; throw SystemError(error_desc, __FILE__, __LINE__); } }