久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

從套接字選擇中跳出

breaking out from socket select(從套接字選擇中跳出)
本文介紹了從套接字選擇中跳出的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我有一個循環,它基本上每隔幾秒(超時后)調用一次:

I have a loop which basically calls this every few seconds (after the timeout):

 while(true){

    if(finished)
       return;

    switch(select(FD_SETSIZE, &readfds, 0, 0, &tv)){
        case SOCKET_ERROR : report bad stuff etc; return;
        default : break;
    }

    // do stuff with the incoming connection
 }

所以基本上每隔幾秒鐘(由電視指定),它就會重新激活聆聽.

So basically for every few seconds (which is specified by tv), it reactivates the listening.

這是在線程 B(不是主線程)上運行的.有時我想從線程 A(主線程)立即結束這個接受器循環,但似乎我必須等到時間間隔結束..

This is run on thread B (not a main thread). There are times when I want to end this acceptor loop immediately from thread A (main thread), but seems like I have to wait until the time interval finishes..

有沒有辦法從另一個線程中斷 select 函數,以便線程 B 可以立即退出?

Is there a way to disrupt the select function from another thread so thread B can quit instantly?

推薦答案

最簡單的方法大概是使用 pipe(2) 創建一個管道并將讀取端添加到 readfds.當另一個線程想要中斷 select() 時,只需向它寫入一個字節,然后再消費它.

The easiest way is probably to use pipe(2) to create a pipe and add the read end to readfds. When the other thread wants to interrupt the select() just write a byte to it, then consume it afterward.

這篇關于從套接字選擇中跳出的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Assertion failed (size.widthgt;0 amp;amp; size.heightgt;0)(斷言失敗(size.width0 amp;amp; size.height0))
Rotate an image in C++ without using OpenCV functions(在 C++ 中旋轉圖像而不使用 OpenCV 函數)
OpenCV: process every frame(OpenCV:處理每一幀)
Why can#39;t I open avi video in openCV?(為什么我不能在 openCV 中打開 avi 視頻?)
OpenCV unable to set up SVM Parameters(OpenCV 無法設置 SVM 參數)
Convert a single color with cvtColor(使用 cvtColor 轉換單一顏色)
主站蜘蛛池模板: 婷婷色国产偷v国产偷v小说 | 水蜜桃亚洲一二三四在线 | 欧美日韩国产一区二区 | 91电影 | 欧美黄色网络 | 久久久夜夜夜 | 成人在线观看免费视频 | 日韩精品在线一区 | 久久一| 九九九久久国产免费 | 成年免费视频 | 一本一道久久a久久精品综合 | 欧美激情第一区 | 黄色一级免费 | 中文字幕亚洲在线 | 羞羞视频网站免费观看 | 国产一区二区三区久久久久久久久 | 午夜视频在线观看一区二区 | 日韩中文字幕一区 | 91天堂| 中文字幕亚洲欧美日韩在线不卡 | 激情毛片 | 日本一区二区影视 | 久久免费高清视频 | 欧美日韩网站 | 色综合一区二区三区 | 欧美成人自拍 | 亚洲精品一二三区 | 狠狠爱一区二区三区 | 国产精品黄视频 | 91精品国产91久久久久久最新 | 国产高清视频一区二区 | 亚洲国产精品99久久久久久久久 | 久久九精品 | 草比av| 精品免费国产视频 | 日韩精品一区二区在线观看 | 99亚洲精品| 99在线播放 | 色综合桃花网 | av大片在线观看 |