久久久久久久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 轉換單一顏色)
主站蜘蛛池模板: 中文字幕精品一区 | 一区欧美 | 日本特黄a级高清免费大片 国产精品久久性 | 精品亚洲永久免费精品 | 99国产精品久久久 | 九九久久精品视频 | 欧美成人一级 | 国产精品日韩 | 成人性视频免费网站 | 亚洲精品视频在线 | 日韩在线一区二区 | 午夜精品久久久久久久久久久久久 | 国产一区二区欧美 | av中文字幕在线 | 久久久国产一区二区三区 | 国产精品久久久久久久久久尿 | 国产精品自产av一区二区三区 | 91av视频 | 日韩久久成人 | 国产精品亚洲一区二区三区在线观看 | 国产亚洲精品久久久久动 | 中文字幕在线观看www | 五月激情婷婷在线 | 欧美日韩在线一区二区 | 国产乱码精品一区二区三区五月婷 | 亚洲精品视频三区 | 亚洲视频欧美视频 | 一道本不卡视频 | 中文字幕精品一区二区三区在线 | 久久一二三区 | 日韩 欧美 二区 | 亚洲成人一区二区 | 精品国产乱码久久久久久影片 | 99久久婷婷国产综合精品 | 亚洲一区视频在线 | 色橹橹欧美在线观看视频高清 | 理论片87福利理论电影 | 国产精品成人在线播放 | 国产一区91精品张津瑜 | 99久久精品免费看国产小宝寻花 | 日本免费在线 |