void CheckTimeout(void) { char command[80]; int time; U64 nps; // Report search speed if (!(nodes % 1000000)) DisplaySpeed(); // We check for timeout or new commands only every so often, // to save some time, unless the engine is operating // in the weakening mode or has received "go nodes" command. // In that cases, we check for timeout as often as we can. if (!Timer.special_mode || Timer.nps_limit > 65535) { if (nodes & 4095 || root_depth == 1) return; } if (Timer.GetData(MAX_NODES) > 0 && nodes >= Timer.GetData(MAX_NODES) ) { abort_search = 1; return; } // Slowdown loop if (Timer.nps_limit && root_depth > 1) { time = Timer.GetElapsedTime() + 1; nps = GetNps(time); while ((int)nps > Timer.nps_limit) { Timer.WasteTime(10); time = Timer.GetElapsedTime() + 1; nps = GetNps(time); if (Timeout()) { abort_search = 1; return; } } } // Process commands that might terminatethe search if (InputAvailable()) { ReadLine(command, sizeof(command)); if (strcmp(command, "stop") == 0) abort_search = 1; else if (strcmp(command, "ponderhit") == 0) pondering = 0; } // Have we already used our allocated time? if (Timeout()) abort_search = 1; }
// Constructs a Timeout instance from a Time that is the 'duration' // from now. static Timeout in(const Duration& duration) { // We need now() + duration < Duration::max() to avoid overflow. // Therefore, we check for now() < duration::max() - duration. if (Clock::now().duration() < Duration::max() - duration) { return Timeout(Clock::now() + duration); } return Timeout(Time::max()); }
int Widget::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QWidget::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: mySignal(); break; case 1: on_toolButton_List_clicked((*reinterpret_cast< bool(*)>(_a[1]))); break; case 2: tableWidget_cellDoubleClicked((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break; case 3: on_toolButton_lrcD_clicked((*reinterpret_cast< bool(*)>(_a[1]))); break; case 4: on_toolButton_next_clicked(); break; case 5: on_toolButton_stop_clicked(); break; case 6: on_toolButton_playpause_clicked(); break; case 7: on_toolButton_previous_clicked(); break; case 8: on_toolButton_open_clicked(); break; case 9: showTime((*reinterpret_cast< qint64(*)>(_a[1]))); break; case 10: Timeout(); break; case 11: musicInformationStateChanged((*reinterpret_cast< Phonon::State(*)>(_a[1])),(*reinterpret_cast< Phonon::State(*)>(_a[2]))); break; case 12: mediaObjectStateChanged((*reinterpret_cast< Phonon::State(*)>(_a[1])),(*reinterpret_cast< Phonon::State(*)>(_a[2]))); break; case 13: musicAboutToFinish(); break; case 14: currentMusicSourceChanged((*reinterpret_cast< Phonon::MediaSource(*)>(_a[1]))); break; case 15: removeSlot(); break; case 16: exitSlot(); break; case 17: iconActivated((*reinterpret_cast< QSystemTrayIcon::ActivationReason(*)>(_a[1]))); break; default: ; } _id -= 18; } return _id; }
void Thread::waitsocket() { fd_set fd; fd_set *writefd = 0; fd_set *readfd = 0; struct timeval timeout; timeout.tv_sec = m_timeout / 1000; timeout.tv_usec = 1000*(m_timeout % 1000); FD_ZERO(&fd); FD_SET(m_socket, &fd); /* now make sure we wait in the correct direction */ int dir(libssh2_session_block_directions(m_session)); if (dir & LIBSSH2_SESSION_BLOCK_INBOUND) readfd = &fd; if (dir & LIBSSH2_SESSION_BLOCK_OUTBOUND) writefd = &fd; int rv(select(m_socket + 1, readfd, writefd, 0, &timeout)); if (rv == -1) { throw Exception("Error in select()"); }else if (rv == 0) { throw Timeout(); } }
void DataContainerImpl::getWriteAccess(const bool waitWithTimeout, const unsigned int timeout) { unique_lock_t lock(m_mutex); try { if(waitWithTimeout) { while(m_readAccessCounter || m_writeAccess) { if(m_cond.wait_for(lock, boost::chrono::milliseconds(timeout)) == boost::cv_status::timeout) { throw Timeout(); } } } else { while(m_readAccessCounter || m_writeAccess) m_cond.wait(lock); } } catch(boost::thread_interrupted&) { throw Interrupt(); } m_writeAccess = true; }
int HECIInitialize(U32 HECIMemBar) { U32 timer_start, timer_end; HECIHostControlReg heci_reg_H_CSR; volatile HECIHostControlReg * heci_reg_H_CSR_ptr = (void *)(HECIMemBar + HECI_HOST_CONTROL_REG); volatile HECIMEControlReg * heci_reg_ME_CSR_HA_ptr = (void *)(HECIMemBar + HECI_ME_CONTROL_HA_REG); // Start 5 second timeout StartTimer(&timer_start, &timer_end, HECI_INIT_TIMEOUT); while (heci_reg_ME_CSR_HA_ptr->r.ME_RDY_HRA == 0) { // If 5 second timeout has expired, return fail if (Timeout(timer_start, timer_end) == 1) return 0; } heci_reg_H_CSR.ul = heci_reg_H_CSR_ptr->ul; // Set H_RDY if it is not set if (heci_reg_H_CSR_ptr->r.H_RDY == 0) { // Clear the host reset, set the host ready bit heci_reg_H_CSR.r.H_RST = 0; heci_reg_H_CSR.r.H_RDY = 1; heci_reg_H_CSR.r.H_IG = 1; heci_reg_H_CSR_ptr->ul = heci_reg_H_CSR.ul; } return 1; }
void Slave::Routine() { uint32 now = time(NULL); if (m_slave_state == SLAVE_STATE_SYNCED) { if (m_ping_recved_time > 0 && now - m_ping_recved_time >= m_serv->m_cfg.repl_timeout) { if (m_slave_state == SLAVE_STATE_SYNCED) { INFO_LOG("now = %u, ping_recved_time=%u", now, m_ping_recved_time); Timeout(); return; } } } if (m_slave_state == SLAVE_STATE_SYNCED || m_slave_state == SLAVE_STATE_LOADING_DUMP_DATA) { if (m_server_support_psync) { Buffer ack; ack.Printf("REPLCONF ACK %lld\r\n", m_backlog.GetReplEndOffset()); m_client->Write(ack); } } m_routine_ts = now; }
void Transfer::Run() { u_int64 t1 = Counter::instance()->tick(); u_int64 basetime = Counter::instance()->tick(); while(_isrun) { Message* m = _msgQueue.pop(); if(m) { Dispatch(m); } #ifndef OPT_NO_TIMEOUT u_int64 nowtime = Counter::instance()->tick(); u_int64 diff = nowtime - basetime; u_int64 t2 = Counter::instance()->tick(); if((t2-t1) > 50) { LOG(LEVEL_INFO, "@@@@@@@@@@@@@@@@@@@ Warning timeout is %dms", t2 - t1); } t1 = t2; if(diff >= 10) { basetime = nowtime; Timeout(); } #endif//OPT_NO_TIMEOUT } }
void Countdown::select_timeout(Handler * s, int timeout) { iterator & pos = s->m_iter_timo; if (timeout < 0) // remove { if (isRegister(pos)) { m_falls[pos->fallidx].erase(pos); pos = null_iter(); } return; } size_t newidx = find_fall_idx(timeout); timeout += m_falls[newidx].m_elasped; if (!isRegister(pos)) // not register, first time pos = m_falls[newidx].insert(Timeout((int)newidx, s, timeout)); else { if (size_t(pos->fallidx) != newidx) { m_falls[newidx].splice(m_falls[pos->fallidx].m_list, pos); pos->fallidx = (int)newidx; } pos->count = timeout; } DUMP_SELECT(); }
int CutyCapt::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QObject::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: DocumentComplete((*reinterpret_cast< bool(*)>(_a[1]))); break; case 1: InitialLayoutCompleted(); break; case 2: JavaScriptWindowObjectCleared(); break; case 3: Timeout(); break; case 4: Delayed(); break; default: ; } _id -= 5; } return _id; }
void TimerManager::Start() { struct timeval timer; for(;;) { // NOTE: on Linux we need to re-initialize timer // everytime we call select(). We might need it on // other platforms as well, so we leave it here for // everyone. // Timeout() also returns how many seconds until next // event, as well as calls any event handlers whose time has come timer.tv_sec = Timeout(); timer.tv_usec = 0; if ( timer.tv_sec == 0 ) { // no timer events registered... only a signal // can save us now!! dprintf(D_DAEMONCORE,"TimerManager::Start() about to block with no events!\n"); select(0,0,0,0,NULL); } else { dprintf(D_DAEMONCORE, "TimerManager::Start() about to block, timeout=%ld\n", (long)timer.tv_sec); select(0,0,0,0, &timer); } } }
void WriteStringZ(const std::string& s, const boost::chrono::system_clock::duration& timeout) { boost::unique_lock<boost::mutex> lock(m_mtx); if (!m_cond.wait_for(lock, timeout, [this, s] { return m_buffer.Available() > s.size(); })) throw Timeout(); m_buffer.WriteStringZ(s.c_str()); lock.unlock(); m_cond.notify_all(); }
void DatabaseConnectionWindow::Show() { if(IsSilent) { QTimer::singleShot(20000,this,SLOT(Timeout())); }else { QTimer::singleShot(3000,this,SLOT(ActivateWindow())); } }
int WarSocket::handle_timeout ( const ACE_Time_Value& time, const void* data ) { Broadcast(Timeout()); // can delete us return 0; }
Stream::size_type Stream::write(const char* buffer, Stream::size_type bufsize, bool flush) const { log_debug("Stream::write " << bufsize << " bytes"); ssize_t n = 0; size_type s = bufsize; // number of bytes left while (true) { do { n = ::write(getFd(), buffer, s); log_debug("::write returns " << n << " errno=" << errno); } while (n < 0 && errno == EINTR); if (n < 0) { if (errno == EAGAIN) n = 0; else { log_error("error in write; errno=" << errno << " (" << strerror(errno) << ')'); throw Exception("write"); } } buffer += n; s -= n; if (s > 0 && n > 0 && !flush) { log_debug("partial write; " << n << " bytes written from " << bufsize << "; return " << (bufsize - s)); return bufsize - s; } if (s <= 0) break; if (getTimeout() <= 0) { log_debug("write timeout (" << getTimeout() << "ms)"); throw Timeout(); } if (poll(POLLOUT) & POLLHUP) { log_debug("eof in write"); return bufsize - s; } } log_debug("full write - return " << bufsize); return bufsize; }
/** * Called when the connect() times out. */ void TCPConnector::TimeoutEvent(PendingTCPConnection *connection) { ConnectionSet::iterator iter = m_connections.find(connection); if (iter == m_connections.end()) { OLA_FATAL << "Timeout triggered but couldn't find the connection this refers to"; } connection->timeout_id = ola::thread::INVALID_TIMEOUT; Timeout(iter); m_connections.erase(iter); }
TimeoutPtr TimedEventQueue::Timeout() { std::lock_guard<std::mutex> lock(m_lock); if (m_timedEvents.empty()) return TimeoutFactory::CreateTimeout(0); auto timer = m_timedEvents.front(); return timer->Timeout(); }
int32 BMidiLocalConsumer::EventThread() { int32 msg_code; ssize_t msg_size; ssize_t buf_size = 100; uint8* buffer = (uint8*) malloc(buf_size); while (true) { if (fTimeout == (bigtime_t) -1) { msg_size = port_buffer_size(fPort); } else { // have timeout msg_size = port_buffer_size_etc(fPort, B_ABSOLUTE_TIMEOUT, fTimeout); if (msg_size == B_TIMED_OUT) { Timeout(fTimeoutData); fTimeout = (bigtime_t) -1; fTimeoutData = NULL; continue; } } if (msg_size < 0) break; // error reading port if (msg_size > buf_size) { buffer = (uint8*) realloc(buffer, msg_size); buf_size = msg_size; } read_port(fPort, &msg_code, buffer, msg_size); if (msg_size > 20) { // minimum valid size #ifdef DEBUG printf("*** received: "); for (int32 t = 0; t < msg_size; ++t) { printf("%02X, ", ((uint8*) buffer)[t]); } printf("\n"); #endif fCurrentProducer = *((uint32*) (buffer + 0)); int32 targetId = *((uint32*) (buffer + 4)); bigtime_t time = *((bigtime_t*) (buffer + 8)); bool atomic = *((bool*) (buffer + 16)); if (targetId == fId) { // only if we are the destination Data((uchar*) (buffer + 20), msg_size - 20, atomic, time); } } } free(buffer); return 0; }
void TCPConnector::CancelAll() { ConnectionSet::iterator iter = m_connections.begin(); for (; iter != m_connections.end(); ++iter) { PendingTCPConnection *connection = *iter; if (connection->timeout_id != ola::thread::INVALID_TIMEOUT) { m_ss->RemoveTimeout(connection->timeout_id); connection->timeout_id = ola::thread::INVALID_TIMEOUT; } Timeout(iter); } m_connections.clear(); }
status_t Worker::Process() { while (true) { BJob* job; status_t status = fJobQueue.Pop(Timeout(), false, &job); if (status != B_OK) return status; status = Run(job); if (status != B_OK) { // TODO: proper error reporting on failed job! debug_printf("Launching %s failed: %s\n", job->Title().String(), strerror(status)); } } }
MemGraph::MemGraph(QWidget* /*parent*/): m_timer(this), m_capacity(GetSharedMemory().get_size()) { setupUi(this); // this sets up GUI // signals/slots mechanism in action connect(historyLength, SIGNAL(valueChanged(double)), this, SLOT(HistoryChanged(double)) ); connect(updatePeriod, SIGNAL(valueChanged(double)), this, SLOT(PeriodChanged(double))); connect(verticalScale, SIGNAL(valueChanged(int)), this, SLOT(ScaleChanged(int))); connect(&m_timer, SIGNAL(timeout()), this, SLOT(Timeout())); m_timer.setSingleShot(true); m_timer.start(static_cast<int>(updatePeriod->value()*1000)); graph->SetHistoryLength(static_cast<int>(historyLength->value()*60)); total->setText(QString::number(m_capacity / 1024 / 1024)); }
SongLoader::SongLoader(LibraryBackendInterface* library, QObject *parent) : QObject(parent), timeout_timer_(new QTimer(this)), playlist_parser_(new PlaylistParser(library, this)), podcast_parser_(new PodcastParser), cue_parser_(new CueParser(library, this)), timeout_(kDefaultTimeout), state_(WaitingForType), success_(false), parser_(NULL), is_podcast_(false), library_(library) { if (sRawUriSchemes.isEmpty()) { sRawUriSchemes << "udp" << "mms" << "mmsh" << "mmst" << "mmsu" << "rtsp" << "rtspu" << "rtspt" << "rtsph" << "spotify"; } timeout_timer_->setSingleShot(true); connect(timeout_timer_, SIGNAL(timeout()), SLOT(Timeout())); }
void MacScreensaver::Inhibit() { timer_.start(30000); Timeout(); }
MacScreensaver::MacScreensaver() { timer_.setInterval(30000); connect(&timer_, SIGNAL(timeout()), SLOT(Timeout())); }
void Store::waitBlock(const BinaryString &digest) { const duration timeout = milliseconds(Config::Get("request_timeout").toDouble())*2; if(!waitBlock(digest, timeout)) throw Timeout(); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow), client(new KelnetClient(this)), Map(NULL) { ui->setupUi(this); connect(client,SIGNAL(Connected()),this,SLOT(Connected())); connect(client,SIGNAL(Disconnected()),this,SLOT(Disconnected())); connect(client,SIGNAL(CoreStatus(QString&)),this,SLOT(NewCoreStatus(QString&))); CoreStatus = new QLabel(this); statusBar()->addPermanentWidget(CoreStatus); Led = new HLed(this); Led->turnOff(); statusBar()->addPermanentWidget(Led); Timer = new QTimer(this); Timer->setInterval(500); connect(this,SIGNAL(TimerStart()),Timer,SLOT(start())); connect(this,SIGNAL(TimerStop()),Timer,SLOT(stop())); connect(Timer,SIGNAL(timeout()),this,SLOT(Timeout())); MapFile = new QLabel(this); MapFile->setText("No map file"); ui->mainToolBar->addSeparator(); ui->mainToolBar->addWidget(MapFile); QStringList header; header << "Name" << "Type" << "Address" << "Period" << "Value" << "Float" << "Modify"; ui->Table->setHorizontalHeaderLabels(header); connect(ui->Table,SIGNAL(AddNewRow()),this,SLOT(AddNewRow())); connect(ui->Table,SIGNAL(EditRow(int)),this,SLOT(EditRow(int))); connect(ui->Table,SIGNAL(DeleteRow(int)),this,SLOT(RemoveRow(int))); connect(ui->Table,SIGNAL(cellDoubleClicked(int,int)),this,SLOT(CellDoubleClicked(int,int))); connect(ui->Table,SIGNAL(cellChanged(int,int)),this,SLOT(CellActivated(int,int))); MapFilePath = "/home/kubanec/workspace/ARMCM4-STM32F407-DISCOVERY/build/test.map"; Map = new MapFileClass(MapFilePath, variables,this); //upper part with plots GraphSplitter = new QSplitter(); ui->verticalLayout_2->addWidget(GraphSplitter); GraphSplitter->setOrientation(Qt::Vertical); GraphSplitter->setContextMenuPolicy(Qt::ActionsContextMenu); GraphSplitter->addAction(ui->actionAdd_new_plot); plotMenu = new QMenu(this); plotMenu->addAction(ui->actionAdd_new_plot); plotMenu->addSeparator(); plotMenu->addAction(ui->actionEdit_plot); plotMenu->addAction(ui->actionRemove_plot); connect(ui->actionRefresh,SIGNAL(triggered()),Map,SLOT(FileChanged())); ui->mainToolBar->insertWidget(ui->actionConnect,ui->toolOpen); ui->mainToolBar->insertSeparator(ui->actionConnect); ui->mainToolBar->insertWidget(ui->actionRefresh,ui->toolMap); connect(ui->toolOpen,SIGNAL(clicked()),this,SLOT(on_actionOpen_triggered())); connect(ui->toolMap,SIGNAL(clicked()),this,SLOT(on_actionMapFile_triggered())); for (int i = 0 ; i < recentHistorySize; i++) { QAction * a = new QAction(ui->toolOpen); ui->toolOpen->addAction(a); connect(a,SIGNAL(triggered()),this,SLOT(action_openFile())); a->setVisible(false); a = new QAction(ui->toolMap); ui->toolMap->addAction(a); connect(a,SIGNAL(triggered()),this,SLOT(action_loadMapFile())); a->setVisible(false); } loadIni(); clearWorkspace(); }
// Constructs a Timeout instance from a Time that is the 'duration' // from now. static Timeout in(const Duration& duration) { return Timeout(Clock::now() + duration); }
void XmppHistoryResponseActor::execute() { qDebug("EXECUTE SignerResponse"); BEGIN_EXECUTE; // Analyze the request { XmppTag* pubsub = m_stanza.child("pubsub"); XmppTag* items = pubsub ? pubsub->child( "items" ) : 0; XmppTag* history = items ? items->child("delta-history") : 0; if ( !history ) { XMPPERROR("Malformed delta-hiistory request"); } // TODO: Inspect the hashes that are being sent bool ok = true; m_start = history->attribute("start-version").toLong(&ok); if ( !ok || m_start < 0) { XMPPERROR("start-version missing"); } m_end = history->attribute("end-version").toLong(&ok); if ( !ok || m_end < 0 ) { XMPPERROR("end-version missing"); } QString waveletName = history->attribute("wavelet-name"); m_url = WaveUrl( waveletName ); if ( m_url.isNull() ) { XMPPERROR("Malformed wavelet-name"); } } // Wait until the connection is ready if ( !connection()->isReady() ) yield( RecvSignal( connection(), SIGNAL(ready())) ); // Send a query to the database asking for the deltas { m_msgId = nextId(); PBMessage<messages::QueryWaveletUpdates>* query = new PBMessage<messages::QueryWaveletUpdates>( ActorId("store", m_url.toString() ), m_msgId ); query->setCreateOnDemand( true ); query->set_wavelet_name(m_url.toString().toStdString() ); query->set_start_version( m_start ); query->set_end_version( m_end ); bool ok = post( query ); if ( !ok ) { XMPPERROR("Internal server error. Could not talk to database."); } } // Wait for a response from the database yield( RecvPB<messages::QueryWaveletUpdatesResponse>(m_msgId) | Timeout(10000) ); if ( REASON(RecvPB<messages::QueryWaveletUpdatesResponse>) ) { if ( !REASON->ok() ) { XMPPERROR("Data base reported an error:" + QString::fromStdString( REASON->error() )); } // Send the requested deltas { QString send; QXmlStreamWriter writer( &send ); writer.writeStartElement("iq"); writer.writeAttribute("type", "result" ); writer.writeAttribute("id", m_stanza.stanzaId() ); writer.writeAttribute("to", connection()->domain() ); writer.writeAttribute("from", Settings::settings()->xmppComponentName() ); writer.writeStartElement("pubsub"); writer.writeAttribute("xmlns", "http://jabber.org/protocol/pubsub" ); writer.writeStartElement("items"); for( i = 0; i < REASON->applied_delta_size(); ++i ) { QByteArray ba = QByteArray::fromRawData( REASON->applied_delta(i).data(), REASON->applied_delta(i).length() ); QString str64 = QString::fromAscii( ba.toBase64() ); writer.writeStartElement("item"); writer.writeStartElement("applied-delta"); writer.writeCDATA( str64 ); writer.writeEndElement(); writer.writeEndElement(); } writer.writeStartElement("item"); writer.writeStartElement("commit-notice"); writer.writeAttribute("xmlns", "http://waveprotocol.org/protocol/0.2/waveserver" ); writer.writeAttribute("version", QString::number(REASON->end_version()) ); writer.writeEndElement(); writer.writeEndElement(); writer.writeStartElement("item"); writer.writeStartElement("history-truncated"); writer.writeAttribute("xmlns", "http://waveprotocol.org/protocol/0.2/waveserver" ); writer.writeAttribute("version", QString::number(REASON->end_version()) ); writer.writeEndElement(); writer.writeEndElement(); writer.writeEndElement(); writer.writeEndElement(); writer.writeEndElement(); connection()->send( send ); } } else { XMPPERROR("Timeout waiting for database"); } END_EXECUTE; }
widget::widget(QWidget *parent) : QWidget(parent,Qt::FramelessWindowHint), ui(new Ui::widget) { ui->setupUi(this); setFixedSize(506,364); isSound = true; ui->hSlider_SongProgress->setRange(0,0); // mList = new musicList(this); // mList->setFixedSize(300,320); // mList->ui->tableWidget->setColumnWidth(0,300); // mList->ui->tableWidget->setColumnWidth(1,150); ui->tableWidget->setAcceptDrops(true); ui->tableWidget->setColumnWidth(0,30); ui->tableWidget->setColumnWidth(1,150); // connect(mList->ui->tableWidget,SIGNAL(cellDoubleClicked(int,int)),SLOT(tableWidget_cellDoubleClicked(int,int))); connect(ui->tableWidget,SIGNAL(cellDoubleClicked(int,int)),SLOT(tableWidget_cellDoubleClicked(int,int))); // mList->show(); // connect(mList,SIGNAL(listClose()),ui->toolButton_List,SLOT(toggle())); // connect(ui->toolButton_open,SIGNAL(triggered),this,SLOT(on_toolButton_open_clicked())); // connect(ui->toolButton_Sound, SIGNAL(triggered),this,SLOT(on_toolButton_List_clicked())); text = new QTextEdit(this); text->hide();//用于查找下句歌词以计算时间间隔 ui->textEdit->setVisible(false);//文本编辑框不可见,(解析歌词) this->setAcceptDrops(true); // this->setFixedSize(300,150); readSettings();//读取上次关闭窗口时窗口的位置 QPalette palette = ui->label_lrc->palette();//设置窗体内歌词颜色 palette.setColor(QPalette::WindowText,Qt::darkBlue); ui->label_lrc->setPalette(palette); lrc = new lrcWindow(0);//桌面歌词 createPlayMode(); createOpenFileMenu(); createContextMenu(); createSystemTrayIcon(); volume = 50; playList=new QMediaPlaylist; playList->setPlaybackMode(QMediaPlaylist::Loop); player=new QMediaPlayer; player->setPlaylist(playList); player->setVolume(volume); ui->hSlider_Volume->setValue(volume); connect(ui->hSlider_SongProgress, SIGNAL(sliderMoved(int)), this, SLOT(setPosition(int))); connect(ui->hSlider_Volume, SIGNAL(sliderMoved(int)), this, SLOT(setSound(int))); connect(ui->action_SingleLoopMode, SIGNAL(triggered()), this, SLOT(setSingleLoopMode())); connect(ui->action_SequentialMode, SIGNAL(triggered()), this, SLOT(setSequentialMode())); connect(ui->action_LoopMode, SIGNAL(triggered()), this, SLOT(setLoopMode())); connect(ui->action_RandomMode, SIGNAL(triggered()), this, SLOT(setRandomMode())); connect(ui->action_About, SIGNAL(triggered()), this, SLOT(aboutUs())); connect(ui->action_Quit, SIGNAL(triggered()), this, SLOT(close())); connect(ui->action_AddFiles,SIGNAL(triggered()), this, SLOT(setAddFiles())); connect(ui->action_AddFileFolder, SIGNAL(triggered()), this, SLOT(setAddFileFolder())); connect(ui->toolButton_close,SIGNAL(clicked()),this, SLOT(close())); connect(ui->toolButton_min,SIGNAL(clicked()),this,SLOT(showMinimized())); connect(player, SIGNAL(positionChanged(qint64)), this, SLOT(positionChanged(qint64))); connect(player, SIGNAL(durationChanged(qint64)), this, SLOT(durationChanged(qint64))); connect(playList, SIGNAL(currentIndexChanged(int)), this, SLOT(updateSongList(int))); // connect(player,SIGNAL(tick(qint64)),this,SLOT(showTime(qint64)));//时间显示与歌词的更新 timer = new QTimer(this);//定时器,若0.1秒不显示歌词,则显示“Music ...” timer->start(100); lrcID = startTimer(100); connect(timer,SIGNAL(timeout()),SLOT(Timeout())); // iconpause = new QIcon(":/images/btn_plause0.png"); // iconplay = new QIcon(":/images/btn_play0.png"); // ui->toolButton_playpause->setIcon(*iconplay); ui->toolButton_playpause->setToolTip(tr("播放")); ui->toolButton_playpause->setStyleSheet("QToolButton{border-image:url(:/images/btn_play0.png);}" "QToolButton:hover{border-image:url(:/images/btn_play1.png);}"); ui->toolButton_stop->setStyleSheet("QToolButton{border-image:url(:/images/btn_stop0.png);}" "QToolButton:hover{border-image:url(:/images/btn_stop1.png);}"); ui->toolButton_previous->setStyleSheet("QToolButton{border-image:url(:/images/btn_pre0.png);}" "QToolButton:hover{border-image:url(:/images/btn_pre1.png);}"); ui->toolButton_next->setStyleSheet("QToolButton{border-image:url(:/images/btn_next0.png);}" "QToolButton:hover{border-image:url(:/images/btn_next1.png);}"); ui->toolButton_open->setStyleSheet("QToolButton{border-image:url(:/images/btn_openFile0.png);}" "QToolButton:hover{border-image:url(:/images/btn_openFile1.png);}"); ui->toolButton_Sound->setStyleSheet("QToolButton{border-image:url(:/images/btn_sound0.png);}" "QToolButton:hover{border-image:url(:/images/btn_sound1.png);}"); ui->toolButton_playMode->setStyleSheet("QToolButton{border-image:url(:/images/seqtional.PNG);}" "QToolButton:hover{border-image:url(:/images/seqtional1.png);}"); ui->toolButton_close->setStyleSheet("QToolButton:hover{border-image:url(:/images/close.png);}"); ui->toolButton_min->setStyleSheet("QToolButton:hover{border-image:url(:/images/min.png);}"); ui->toolButton_mintray->setStyleSheet("QToolButton:hover{border-image:url(:/images/mintray.png);}"); ui->toolButton_toolstyle->setStyleSheet("QToolButton:hover{border-image:url(:/images/toolstyle.png);}"); ui->toolButton_main->setStyleSheet("QToolButton:hover{border-image:url(:/images/main.png);}"); ui->toolButton_showfront->setStyleSheet("QToolButton:hover{border-image:url(:/images/showfront.png);}"); ui->toolButton_p->setStyleSheet("QToolButton:hover{border-image:url(:/images/putup.png);}"); ui->toolButton_s->setStyleSheet("QToolButton:hover{border-image:url(:/images/spin.png);}"); ui->toolButton_lrcD->setStyleSheet("QToolButton:hover{background:rgb(0,255,255,100)}"); ui->label_Title->setStyleSheet("QLabel:hover{color: rgb(85, 255, 255);}"); QPalette p = this->palette(); p.setColor(QPalette::WindowText,QColor(0,255,255)); ui->label_palyname->setPalette(p); p.setColor(QPalette::WindowText,QColor(255,190,0)); ui->label_lrc->setPalette(p); // mList->installEventFilter(this); // mList->ui->tableWidget->installEventFilter(this);//事件过滤器 ui->tableWidget->installEventFilter(this); // connect(audioOutput,SIGNAL(mutedChanged(bool)),sound,SLOT(setChecked(bool))); connect(this,SIGNAL(mySignal()),this,SLOT(close()),Qt::QueuedConnection); init(playList); // mList->show(); // addToPlayList(); }
//Transmission and reception of SOCKS protocol(UDP) size_t __fastcall SOCKSUDPRequest( const char *OriginalSend, const size_t SendSize, PSTR OriginalRecv, const size_t RecvSize) { //Initialization std::shared_ptr<char> SendBuffer(new char[LARGE_PACKET_MAXSIZE]()); std::shared_ptr<SOCKET_DATA> TCPSocketData, UDPSocketData(new SOCKET_DATA()), LocalSocketData; memset(SendBuffer.get(), 0, LARGE_PACKET_MAXSIZE); memset(UDPSocketData.get(), 0, sizeof(SOCKET_DATA)); if (!Parameter.SOCKS_UDP_NoHandshake) { std::shared_ptr<SOCKET_DATA> TCPSocketDataTemp(new SOCKET_DATA()), LocalSocketDataTemp(new SOCKET_DATA()); TCPSocketDataTemp.swap(TCPSocketData); LocalSocketDataTemp.swap(LocalSocketData); memset(TCPSocketData.get(), 0, sizeof(SOCKET_DATA)); memset(LocalSocketData.get(), 0, sizeof(SOCKET_DATA)); } //Socket initialization if (Parameter.SOCKS_Address_IPv6.Storage.ss_family > 0 && //IPv6 (Parameter.SOCKS_Protocol_Network == REQUEST_MODE_NETWORK_BOTH && GlobalRunningStatus.GatewayAvailable_IPv6 || //Auto select Parameter.SOCKS_Protocol_Network == REQUEST_MODE_IPV6 || //IPv6 Parameter.SOCKS_Protocol_Network == REQUEST_MODE_IPV4 && Parameter.SOCKS_Address_IPv4.Storage.ss_family == 0)) //Non-IPv4 { if (!Parameter.SOCKS_UDP_NoHandshake) { //TCP process TCPSocketData->SockAddr.ss_family = AF_INET6; ((PSOCKADDR_IN6)&TCPSocketData->SockAddr)->sin6_addr = Parameter.SOCKS_Address_IPv6.IPv6.sin6_addr; ((PSOCKADDR_IN6)&TCPSocketData->SockAddr)->sin6_port = Parameter.SOCKS_Address_IPv6.IPv6.sin6_port; TCPSocketData->AddrLen = sizeof(sockaddr_in6); TCPSocketData->Socket = socket(AF_INET6, SOCK_STREAM, IPPROTO_TCP); //Local process LocalSocketData->SockAddr.ss_family = AF_INET6; LocalSocketData->AddrLen = sizeof(sockaddr_in6); } //UDP process UDPSocketData->SockAddr.ss_family = AF_INET6; ((PSOCKADDR_IN6)&UDPSocketData->SockAddr)->sin6_addr = Parameter.SOCKS_Address_IPv6.IPv6.sin6_addr; if (Parameter.SOCKS_UDP_NoHandshake) ((PSOCKADDR_IN6)&UDPSocketData->SockAddr)->sin6_port = Parameter.SOCKS_Address_IPv6.IPv6.sin6_port; UDPSocketData->AddrLen = sizeof(sockaddr_in6); UDPSocketData->Socket = socket(AF_INET6, SOCK_DGRAM, IPPROTO_UDP); } else if (Parameter.SOCKS_Address_IPv4.Storage.ss_family > 0 && //IPv4 (Parameter.SOCKS_Protocol_Network == REQUEST_MODE_NETWORK_BOTH && GlobalRunningStatus.GatewayAvailable_IPv4 || //Auto select Parameter.SOCKS_Protocol_Network == REQUEST_MODE_IPV4 || //IPv4 Parameter.SOCKS_Protocol_Network == REQUEST_MODE_IPV6 && Parameter.SOCKS_Address_IPv6.Storage.ss_family == 0)) //Non-IPv6 { if (!Parameter.SOCKS_UDP_NoHandshake) { //TCP process TCPSocketData->SockAddr.ss_family = AF_INET; ((PSOCKADDR_IN)&TCPSocketData->SockAddr)->sin_addr = Parameter.SOCKS_Address_IPv4.IPv4.sin_addr; ((PSOCKADDR_IN)&TCPSocketData->SockAddr)->sin_port = Parameter.SOCKS_Address_IPv4.IPv4.sin_port; TCPSocketData->AddrLen = sizeof(sockaddr_in); TCPSocketData->Socket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); //Local process LocalSocketData->SockAddr.ss_family = AF_INET; LocalSocketData->AddrLen = sizeof(sockaddr_in); } //UDP process UDPSocketData->SockAddr.ss_family = AF_INET; ((PSOCKADDR_IN)&UDPSocketData->SockAddr)->sin_addr = Parameter.SOCKS_Address_IPv4.IPv4.sin_addr; if (Parameter.SOCKS_UDP_NoHandshake) ((PSOCKADDR_IN)&UDPSocketData->SockAddr)->sin_port = Parameter.SOCKS_Address_IPv4.IPv4.sin_port; UDPSocketData->AddrLen = sizeof(sockaddr_in); UDPSocketData->Socket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); } else { return EXIT_FAILURE; } //Socket check if (!Parameter.SOCKS_UDP_NoHandshake && !SocketSetting(TCPSocketData->Socket, SOCKET_SETTING_INVALID_CHECK, nullptr) || !SocketSetting(UDPSocketData->Socket, SOCKET_SETTING_INVALID_CHECK, nullptr)) { closesocket(UDPSocketData->Socket); if (!Parameter.SOCKS_UDP_NoHandshake) closesocket(TCPSocketData->Socket); PrintError(LOG_ERROR_NETWORK, L"SOCKS socket initialization error", 0, nullptr, 0); return EXIT_FAILURE; } //Non-blocking mode setting if (!Parameter.SOCKS_UDP_NoHandshake && !SocketSetting(TCPSocketData->Socket, SOCKET_SETTING_NON_BLOCKING_MODE, nullptr) || !SocketSetting(UDPSocketData->Socket, SOCKET_SETTING_NON_BLOCKING_MODE, nullptr)) { closesocket(UDPSocketData->Socket); if (!Parameter.SOCKS_UDP_NoHandshake) closesocket(TCPSocketData->Socket); PrintError(LOG_ERROR_NETWORK, L"Socket non-blocking mode setting error", 0, nullptr, 0); return EXIT_FAILURE; } //Selecting structure setting std::shared_ptr<fd_set> ReadFDS(new fd_set()), WriteFDS(new fd_set()); std::shared_ptr<timeval> Timeout(new timeval()); memset(ReadFDS.get(), 0, sizeof(fd_set)); memset(WriteFDS.get(), 0, sizeof(fd_set)); memset(Timeout.get(), 0, sizeof(timeval)); //UDP transmission of standard SOCKS protocol must connect with TCP to server first. if (!Parameter.SOCKS_UDP_NoHandshake) { //Selection exchange process if (!SOCKSSelectionExchange(TCPSocketData.get(), ReadFDS.get(), WriteFDS.get(), Timeout.get(), SendBuffer.get(), OriginalRecv, RecvSize)) { shutdown(UDPSocketData->Socket, SD_BOTH); shutdown(TCPSocketData->Socket, SD_BOTH); closesocket(UDPSocketData->Socket); closesocket(TCPSocketData->Socket); return EXIT_FAILURE; } else { memset(SendBuffer.get(), 0, LARGE_PACKET_MAXSIZE); } //UDP connecting and get UDP socket infomation. if (SocketConnecting(IPPROTO_UDP, UDPSocketData->Socket, (PSOCKADDR)&UDPSocketData->SockAddr, UDPSocketData->AddrLen, nullptr, 0) == EXIT_FAILURE || getsockname(UDPSocketData->Socket, (PSOCKADDR)&LocalSocketData->SockAddr, &LocalSocketData->AddrLen) == SOCKET_ERROR) { shutdown(UDPSocketData->Socket, SD_BOTH); shutdown(TCPSocketData->Socket, SD_BOTH); closesocket(UDPSocketData->Socket); closesocket(TCPSocketData->Socket); PrintError(LOG_ERROR_NETWORK, L"SOCKS connecting error", 0, nullptr, 0); return EXIT_FAILURE; } //Client command request process if (!SOCKSClientCommandRequest(IPPROTO_UDP, TCPSocketData->Socket, ReadFDS.get(), WriteFDS.get(), Timeout.get(), SendBuffer.get(), OriginalRecv, RecvSize, LocalSocketData.get())) { shutdown(UDPSocketData->Socket, SD_BOTH); shutdown(TCPSocketData->Socket, SD_BOTH); closesocket(UDPSocketData->Socket); closesocket(TCPSocketData->Socket); return EXIT_FAILURE; } else { memset(SendBuffer.get(), 0, LARGE_PACKET_MAXSIZE); //Copy network infomation from server message. if (UDPSocketData->SockAddr.ss_family == AF_INET6) ((PSOCKADDR_IN6)&UDPSocketData->SockAddr)->sin6_port = ((PSOCKADDR_IN6)&LocalSocketData->SockAddr)->sin6_port; else ((PSOCKADDR_IN)&UDPSocketData->SockAddr)->sin_port = ((PSOCKADDR_IN)&LocalSocketData->SockAddr)->sin_port; } } //UDP connecting again if (SocketConnecting(IPPROTO_UDP, UDPSocketData->Socket, (PSOCKADDR)&UDPSocketData->SockAddr, UDPSocketData->AddrLen, nullptr, 0) == EXIT_FAILURE) { if (!Parameter.SOCKS_UDP_NoHandshake) { shutdown(TCPSocketData->Socket, SD_BOTH); closesocket(TCPSocketData->Socket); } PrintError(LOG_ERROR_NETWORK, L"SOCKS connecting error", 0, nullptr, 0); return EXIT_FAILURE; } //SOCKS UDP relay header SSIZE_T RecvLen = sizeof(socks_udp_relay_request); void *SOCKS_Pointer = SendBuffer.get(); if (Parameter.SOCKS_TargetServer.Storage.ss_family == AF_INET6) //IPv6 { ((psocks_udp_relay_request)SOCKS_Pointer)->Address_Type = SOCKS5_ADDRESS_IPV6; SOCKS_Pointer = SendBuffer.get() + RecvLen; RecvLen += (SSIZE_T)sizeof(in6_addr); *(in6_addr *)SOCKS_Pointer = Parameter.SOCKS_TargetServer.IPv6.sin6_addr; SOCKS_Pointer = SendBuffer.get() + RecvLen; RecvLen += (SSIZE_T)sizeof(uint16_t); *(PUINT16)SOCKS_Pointer = Parameter.SOCKS_TargetServer.IPv6.sin6_port; } else if (Parameter.SOCKS_TargetServer.Storage.ss_family == AF_INET) //IPv4 { ((psocks_udp_relay_request)SOCKS_Pointer)->Address_Type = SOCKS5_ADDRESS_IPV4; SOCKS_Pointer = SendBuffer.get() + RecvLen; RecvLen += (SSIZE_T)sizeof(in_addr); *(in_addr *)SOCKS_Pointer = Parameter.SOCKS_TargetServer.IPv4.sin_addr; SOCKS_Pointer = SendBuffer.get() + RecvLen; RecvLen += (SSIZE_T)sizeof(uint16_t); *(PUINT16)SOCKS_Pointer = Parameter.SOCKS_TargetServer.IPv4.sin_port; } else if (Parameter.SOCKS_TargetDomain != nullptr && Parameter.SOCKS_TargetDomain_Length > 0) //Damain { ((psocks_udp_relay_request)SOCKS_Pointer)->Address_Type = SOCKS5_ADDRESS_DOMAIN; SOCKS_Pointer = SendBuffer.get() + RecvLen; RecvLen += (SSIZE_T)sizeof(uint8_t); *(PUINT8)SOCKS_Pointer = (uint8_t)Parameter.SOCKS_TargetDomain_Length; SOCKS_Pointer = SendBuffer.get() + RecvLen; memcpy_s(SOCKS_Pointer, (SSIZE_T)LARGE_PACKET_MAXSIZE - ((SSIZE_T)sizeof(socks_udp_relay_request) + RecvLen), Parameter.SOCKS_TargetDomain, Parameter.SOCKS_TargetDomain_Length); RecvLen += (SSIZE_T)Parameter.SOCKS_TargetDomain_Length; SOCKS_Pointer = SendBuffer.get() + RecvLen; *(PUINT16)SOCKS_Pointer = Parameter.SOCKS_TargetDomain_Port; RecvLen += (SSIZE_T)sizeof(uint16_t); } else { shutdown(UDPSocketData->Socket, SD_BOTH); closesocket(UDPSocketData->Socket); if (!Parameter.SOCKS_UDP_NoHandshake) { shutdown(TCPSocketData->Socket, SD_BOTH); closesocket(TCPSocketData->Socket); } return EXIT_FAILURE; } memcpy_s(SendBuffer.get() + RecvLen, RecvSize, OriginalSend, SendSize); RecvLen += (SSIZE_T)SendSize; //Data exchange RecvLen = SOCKSSocketSelecting(UDPSocketData->Socket, ReadFDS.get(), WriteFDS.get(), Timeout.get(), SendBuffer.get(), RecvLen, OriginalRecv, RecvSize, sizeof(socks_udp_relay_request) + DNS_PACKET_MINSIZE); shutdown(UDPSocketData->Socket, SD_BOTH); closesocket(UDPSocketData->Socket); if (!Parameter.SOCKS_UDP_NoHandshake) { shutdown(TCPSocketData->Socket, SD_BOTH); closesocket(TCPSocketData->Socket); } if (RecvLen >= (SSIZE_T)DNS_PACKET_MINSIZE) { //Remove SOCKS UDP relay header SOCKS_Pointer = OriginalRecv; if (Parameter.SOCKS_TargetServer.Storage.ss_family == AF_INET6 && //IPv6 ((psocks_udp_relay_request)SOCKS_Pointer)->Address_Type == SOCKS5_ADDRESS_IPV6 && RecvLen >= (SSIZE_T)(sizeof(socks_udp_relay_request) + sizeof(in6_addr) + sizeof(uint16_t) + DNS_PACKET_MINSIZE) && memcmp((in6_addr *)(OriginalRecv + sizeof(socks_udp_relay_request)), &Parameter.SOCKS_TargetServer.IPv6.sin6_addr, sizeof(in6_addr)) == EXIT_SUCCESS && *(uint16_t *)(OriginalRecv + sizeof(socks_udp_relay_request) + sizeof(in6_addr)) == Parameter.SOCKS_TargetServer.IPv6.sin6_port) { memmove_s(OriginalRecv, RecvSize, OriginalRecv + sizeof(socks_udp_relay_request) + sizeof(in6_addr) + sizeof(uint16_t), RecvLen - (SSIZE_T)(sizeof(socks_udp_relay_request) + sizeof(in6_addr) + sizeof(uint16_t))); return RecvLen - (SSIZE_T)(sizeof(socks_udp_relay_request) + sizeof(in6_addr) + sizeof(uint16_t)); } else if (Parameter.SOCKS_TargetServer.Storage.ss_family == AF_INET && //IPv4 ((psocks_udp_relay_request)SOCKS_Pointer)->Address_Type == SOCKS5_ADDRESS_IPV4 && RecvLen >= (SSIZE_T)(sizeof(socks_udp_relay_request) + sizeof(in_addr) + sizeof(uint16_t) + DNS_PACKET_MINSIZE) && (*(in_addr *)(OriginalRecv + sizeof(socks_udp_relay_request))).S_un.S_addr == Parameter.SOCKS_TargetServer.IPv4.sin_addr.S_un.S_addr && *(uint16_t *)(OriginalRecv + sizeof(socks_udp_relay_request) + sizeof(in_addr)) == Parameter.SOCKS_TargetServer.IPv4.sin_port) { memmove_s(OriginalRecv, RecvSize, OriginalRecv + sizeof(socks_udp_relay_request) + sizeof(in_addr) + sizeof(uint16_t), RecvLen - (SSIZE_T)(sizeof(socks_udp_relay_request) + sizeof(in_addr) + sizeof(uint16_t))); return RecvLen - (SSIZE_T)(sizeof(socks_udp_relay_request) + sizeof(in_addr) + sizeof(uint16_t)); } else if (Parameter.SOCKS_TargetDomain != nullptr && Parameter.SOCKS_TargetDomain_Length > 0) //Domain /* SOCKS server will reply IPv4/IPv6 address of domain. ((psocks_udp_relay_request)SOCKS_Pointer)->Address_Type == SOCKS5_ADDRESS_DOMAIN && RecvLen >= (SSIZE_T)(sizeof(socks_udp_relay_request) + sizeof(uint8_t) + Parameter.SOCKS_TargetDomain_Length + sizeof(uint16_t) + DNS_PACKET_MINSIZE) && *(uint8_t *)(OriginalRecv + sizeof(socks_udp_relay_request)) == Parameter.SOCKS_TargetDomain_Length && memcmp(OriginalRecv + sizeof(socks_udp_relay_request) + sizeof(uint8_t), Parameter.SOCKS_TargetDomain, Parameter.SOCKS_TargetDomain_Length) == EXIT_SUCCESS && *(uint16_t *)(OriginalRecv + sizeof(socks_udp_relay_request) + sizeof(uint8_t) + Parameter.SOCKS_TargetDomain_Length) == Parameter.SOCKS_TargetDomain_Port) */ { //IPv6 if (((psocks_udp_relay_request)SOCKS_Pointer)->Address_Type == SOCKS5_ADDRESS_IPV6 && RecvLen >= (SSIZE_T)(sizeof(socks_udp_relay_request) + sizeof(in6_addr) + sizeof(uint16_t) + DNS_PACKET_MINSIZE)) { memmove_s(OriginalRecv, RecvSize, OriginalRecv + sizeof(socks_udp_relay_request) + sizeof(in6_addr) + sizeof(uint16_t), RecvLen - (SSIZE_T)(sizeof(socks_udp_relay_request) + sizeof(in6_addr) + sizeof(uint16_t))); return RecvLen - (SSIZE_T)(sizeof(socks_udp_relay_request) + sizeof(in6_addr) + sizeof(uint16_t)); } //IPv4 else if (((psocks_udp_relay_request)SOCKS_Pointer)->Address_Type == SOCKS5_ADDRESS_IPV4 && RecvLen >= (SSIZE_T)(sizeof(socks_udp_relay_request) + sizeof(in_addr) + sizeof(uint16_t) + DNS_PACKET_MINSIZE)) { memmove_s(OriginalRecv, RecvSize, OriginalRecv + sizeof(socks_udp_relay_request) + sizeof(in_addr) + sizeof(uint16_t), RecvLen - (SSIZE_T)(sizeof(socks_udp_relay_request) + sizeof(in_addr) + sizeof(uint16_t))); return RecvLen - (SSIZE_T)(sizeof(socks_udp_relay_request) + sizeof(in_addr) + sizeof(uint16_t)); } // memmove_s(OriginalRecv, RecvSize, OriginalRecv + sizeof(socks_udp_relay_request) + sizeof(uint8_t) + Parameter.SOCKS_TargetDomain_Length + sizeof(uint16_t), RecvLen - (SSIZE_T)(sizeof(socks_udp_relay_request) + sizeof(uint8_t) + Parameter.SOCKS_TargetDomain_Length + sizeof(uint16_t))); // return RecvLen - (SSIZE_T)(sizeof(socks_udp_relay_request) + sizeof(uint8_t) + Parameter.SOCKS_TargetDomain_Length + sizeof(uint16_t)); } } return EXIT_FAILURE; }