/* * main() */ int main (int argc, char **argv) { if (init_socket(&sockfd) < 0) { printf("Init the socket failed.\n"); return -1; } /* * Clean fd set. */ FD_ZERO(&active_fd_set); FD_SET(sockfd, &active_fd_set); max_fd = sockfd; while (1) { int err; struct timeval tv; fd_set read_fds; // Only use in current run. /* * Set select timeout. */ tv.tv_sec = 5; tv.tv_usec = 0; /* * Copy fd set. */ read_fds = active_fd_set; err = select(max_fd + 1, &read_fds, NULL, NULL, &tv); if (err == -1) { perror("select()"); return -1; } else if (err == 0) { printf("Select timeout\n"); continue; } else { /* * Service all sockets. */ int i; for (i = 0; i < FD_SETSIZE; i++) { if (FD_ISSET(i, &read_fds)) { if (i == sockfd) { accept_cb(); } else { read_cb(i); } } } // end of for } // end of if } // end of while return 0; }
MM_BEGIN_NAMESPACE PreferencesDialog::PreferencesDialog(MainWindow* mainWindow, QWidget* parent) : QDialog(parent) { _main_window = mainWindow; // static const int width = 600; // static const int height = 400; // resize(MainWindow::OUTPUT_WINDOW_MINIMUM_WIDTH, MainWindow::OUTPUT_WINDOW_MINIMUM_HEIGHT); // OSC port number QLabel* osc_port_label = new QLabel(tr("OSC port number")); _osc_port_numbox = new QSpinBox; _osc_port_numbox->setRange(1024, 65534); QLayout* hbox_osc_port = new QHBoxLayout; hbox_osc_port->addWidget(osc_port_label); hbox_osc_port->addWidget(_osc_port_numbox); // cancel / ok _button_box = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); connect(_button_box, SIGNAL(accepted()), this, SLOT(accept_cb())); connect(_button_box, SIGNAL(rejected()), this, SLOT(reject_cb())); //QLayout* hbox_confirm = new QHBoxLayout; //hbox_confirm->addWidget(_button_box); hbox_osc_port->addWidget(_button_box); // pack all rows //QLayout* vbox = new QVBoxLayout; //vbox->addWidget(hbox_osc_port); setLayout(hbox_osc_port); this->resetValues(); }