青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

隨筆 - 7  文章 - 6  trackbacks - 0
<2025年9月>
31123456
78910111213
14151617181920
21222324252627
2829301234
567891011

常用鏈接

留言簿(1)

隨筆檔案

文章分類

搜索

  •  

積分與排名

  • 積分 - 33128
  • 排名 - 615

最新評論

閱讀排行榜

評論排行榜

To understand the backlog argument, we must realize that for a given listening socket, the kernel maintains two queues :
要明白backlog參數(shù)的含義,我們必須明白對于一個listening socket,kernel維護者兩個隊列:

1.An incomplete connection queue, which contains an entry for each SYN that has arrived from a client for which the server is awaiting completion of the TCP three-way handshake. These sockets are in the SYN_RCVD state .
1.一個未完成連接的隊列,此隊列維護著那些已收到了客戶端SYN分節(jié)信息,等待完成三路握手的連接,socket的狀態(tài)是SYN_RCVD

2.A completed connection queue, which contains an entry for each client with whom the TCP three-way handshake has completed. These sockets are in the ESTABLISHED state
2.一個已完成的連接的隊列,此隊列包含了那些已經(jīng)完成三路握手的連接,socket的狀態(tài)是ESTABLISHED

The backlog argument to the listen function has historically specified the maximum value for the sum of both queues.
backlog參數(shù)歷史上被定義為上面兩個隊列的大小之和

Berkeley-derived implementations add a fudge factor to the backlog: It is multiplied by 1.5
Berkely實現(xiàn)中的backlog值為上面兩隊列之和再乘以1.5

When a SYN arrives from a client, TCP creates a new entry on the incomplete queue and then responds with the second segment of the three-way handshake: the server's SYN with an ACK of the client's SYN (Section 2.6). This entry will remain on the incomplete queue until the third segment of the three-way handshake arrives (the client's ACK of the server's SYN), or until the entry times out. (Berkeley-derived implementations have a timeout of 75 seconds for these incomplete entries.)
當客戶端的第一個SYN到達的時候,TCP會在未完成隊列中增加一個新的記錄然后回復給客戶端三路握手中的第二個分節(jié)(服務(wù)端的SYN和針對客戶端的ACK),這條記錄會在未完成隊列中一直存在,直到三路握手中的最后一個分節(jié)到達,或者直到超時(Berkeley時間將這個超時定義為75秒)

If the queues are full when a client SYN arrives, TCP ignores the arriving SYN (pp. 930–931 of TCPv2); it does not send an RST. This is because the condition is considered temporary, and the client TCP will retransmit its SYN, hopefully finding room on the queue in the near future. If the server TCP immediately responded with an RST, the client's connect would return an error, forcing the application to handle this condition instead of letting TCP's normal retransmission take over. Also, the client could not differentiate between an RST in response to a SYN meaning "there is no server at this port" versus "there is a server at this port but its queues are full."
如果當客戶端SYN到達的時候隊列已滿,TCP將會忽略后續(xù)到達的SYN,但是不會給客戶端發(fā)送RST信息,因為此時允許客戶端重傳SYN分節(jié),如果返回錯誤信息,那么客戶端將無法分清到底是服務(wù)端對應端口上沒有相應應用程序還是服務(wù)端對應端口上隊列已滿這兩種情況

posted @ 2010-02-07 19:43 許海斌 閱讀(18834) | 評論 (2)編輯 收藏

        今天看到有人在問這個問題,寫了下代碼,標準庫分離了算法和數(shù)據(jù)結(jié)構(gòu),按照這個框架寫程序確實比較方便,個人認為熟讀和透徹理解標準庫源碼是每個想成為資深c++程序員的必修課,就框架結(jié)構(gòu)而論,stl很好的分離了算法和數(shù)據(jù)結(jié)構(gòu),就算法而論,標準庫里有很多常見算法的經(jīng)典實現(xiàn),所以有非常高的研究價值。

#include <iostream>
#include 
<stddef.h>
#include 
<stdlib.h>
#include 
<string>
#include 
<iterator>
#include 
<algorithm>
#include 
<vector>

using namespace std;

template 
<typename InputIterator1, typename InputIterator2, typename OutputIterator>
OutputIterator delete_intersection(InputIterator1 first1, InputIterator1 last1, 
         InputIterator2 first2, InputIterator2 last2, OutputIterator dest) 
{
    
while (first1 != last1 && first2 != last2) {
        
if (*first1 > *first2) {
            
*dest = *first2;
            
++first2;
            
++dest;
        }
 else if (*first1 < *first2) {
            
*dest = *first1;
            
++first1;
            
++dest;
        }
 else {
            
++first1;
            
++first2;
        }

    }


    
for (;first2 != last2; ++first2) *dest = *first2;

    
return dest;
}


int main() {
    
int a[] = {1,1,2,2,5,6,9,9};
    
int b[] = {1,2,3,4,4,6,7,8,9,9,9,10};

    vector
<int> vc;

    delete_intersection(a, a 
+ sizeof(a)/sizeof(a[0]), b, b + sizeof(b)/sizeof(b[0]), back_inserter(vc));

    std::copy(a, a 
+ sizeof(a)/sizeof(a[0]), ostream_iterator<int>(cout, ",")); 
        cout 
<< endl;

    std::copy(b, b 
+ sizeof(b)/sizeof(b[0]), ostream_iterator<int>(cout, ",")); 
        cout 
<< endl;

    std::copy(vc.begin(), vc.end(), ostream_iterator
<int>(cout, ",")); 
        cout 
<< endl;

    ::system(
"PAUSE");
    
return EXIT_SUCCESS;

}
posted @ 2009-03-05 18:56 許海斌 閱讀(1099) | 評論 (4)編輯 收藏
boost的線程庫不能強行終止,所以通過time_wait可以讓其自然的結(jié)束

 1
 #include <iostream>
 2 #include <boost/thread/thread.hpp>
 3 #include <boost/thread/mutex.hpp>
 4 #include <boost/thread/condition.hpp>
 5 #include <boost/date_time/posix_time/posix_time.hpp>
 6 
 7 using namespace std;
 8 using namespace boost;
 9 
10 boost::mutex test_mutex;
11 boost::condition_variable test_condition;
12 
13 void test() {
14 
15     for (;;) {
16         
17         boost::mutex::scoped_lock lock(test_mutex);
18         if (test_condition.timed_wait(lock, get_system_time() + posix_time::seconds(3))) {
19             cout << "成功接收到通知" << endl; //這里加個break就結(jié)束了
20         } else {
21             cout << "沒有等待到通知" << endl;
22         }
23 
24     }
25 }
26 
27 int main() {
28 
29     boost::thread test_thread(test);
30 
31     for (;;) {
32         ::system("PAUSE");
33         cout << "開始發(fā)送通知" << endl;
34         test_condition.notify_one();
35     }
36 
37 }

posted @ 2009-02-19 17:18 許海斌 閱讀(5133) | 評論 (0)編輯 收藏
在泛型編程中,對于一個concept的一系列modeling,尤其是這些modeling中還有c++基本類型的時候,如果要抽取其特性,可以用一個traits類來解決,traits的名稱可命名為concept名稱_traits,對于其中的基本類型的traits可以用類模板的偏特化實現(xiàn)。
posted @ 2009-02-09 17:59 許海斌 閱讀(1549) | 評論 (0)編輯 收藏

實現(xiàn)代碼:

    typedef enum { UNIQUE_LOCK, SHARED_LOCK } LockType;

template<LockType lt>
class shared_lock;

template 
<>
class shared_lock<UNIQUE_LOCK>private boost::noncopyable {
public:
    shared_lock(boost::shared_mutex
& sm): sm_(sm) sm_.lock(); }
    
~shared_lock() { sm_.unlock(); }
private:
    boost::shared_mutex
& sm_;
}
;

template 
<>
class shared_lock<SHARED_LOCK>private boost::noncopyable {
public:
    shared_lock(boost::shared_mutex
& sm): sm_(sm) sm_.lock_shared(); }
    
~shared_lock() { sm_.unlock_shared(); }
private:
    boost::shared_mutex
& sm_;
}
;



調(diào)用方式:

    boost::shared_mutex session_mutex_;

//獨占鎖定
shared_lock<UNIQUE_LOCK> lock(session_mutex_);

//共享鎖定
shared_lock<SHARED_LOCK> lock(session_mutex_);


http://m.shnenglu.com/thisisbin/archive/2009/01/21/72417.html 一文 single-write/multi-read 就可以應用這種RAII風格的共享鎖實

posted @ 2009-01-22 10:22 許海斌 閱讀(1391) | 評論 (0)編輯 收藏
    程序中幾個線程一起往控制臺寫入log_info,但是可以很清楚的看到begin or write_process不會同時連續(xù)的出現(xiàn),而且在begin of write_process和end of write_process之間肯定不會出現(xiàn)begin of read_process或者end of read_process。但是begin of read_process卻會在控制臺上連續(xù)出現(xiàn),這說明在同一時刻只有一個write_prcess在運行,但是wrte_process沒有運行的時候,會有多個read_process并發(fā)運行。

 1 #include <iostream>
 2 
 3 #include <boost/thread/thread.hpp>
 4 #include <boost/thread/shared_mutex.hpp>
 5 
 6 using namespace std;
 7 using namespace boost;
 8 
 9 boost::shared_mutex shr_mutex;
10 
11 /// 這個是輔助類,能夠保證log_info被完整的輸出
12 class safe_log {
13 public:
14     static void log(const std::string& log_info) {
15         boost::mutex::scoped_lock lock(log_mutex);
16         cout << log_info << endl;
17     }
18 
19 private:
20     static boost::mutex log_mutex;
21 };
22 
23 boost::mutex safe_log::log_mutex;
24 
25 void write_process() {
26     shr_mutex.lock();
27     safe_log::log("begin of write_process");
28     safe_log::log("end of write_process");
29     shr_mutex.unlock();
30 }
31 
32 void read_process() {
33     shr_mutex.lock_shared();
34     safe_log::log("begin of read_process");
35     safe_log::log("end of read_process");
36     shr_mutex.unlock_shared();
37 }
38 
39 int main() {
40 
41     thread_group threads;
42     for (int i = 0; i < 10++ i) {
43         threads.create_thread(&write_process);
44         threads.create_thread(&read_process);
45     }
46 
47     threads.join_all();
48 
49     ::system("PAUSE");
50 
51     return 0;
52 }

posted @ 2009-01-21 13:58 許海斌 閱讀(2678) | 評論 (0)編輯 收藏

1、安裝stlport,參考文章:http://www.cnblogs.com/DonLiang/archive/2007/10/13/923143.html
如果是DEBUG模式請在項目的屬性=>配置屬性=>c/c++=>命令行的附加選項增加/D_STLP_DEBUG

2、boost_1_37_0\tools\jam\stage下運行build.bat編譯生成bjam.exe并拷貝到boost根目錄

3、修改配置文件boost_1_37_0\tools\build\v2\user-config.jam,將兩個stlport選項打開

4、vs2005命令提示下編譯命令:bjam stdlib=stlport --build-type=complete install,接下來是漫長的等待,大概兩個小時以上吧

posted @ 2008-12-09 13:22 許海斌 閱讀(1994) | 評論 (0)編輯 收藏
僅列出標題  
青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            一区二区欧美国产| 亚洲福利免费| 欧美黄色视屏| 久久精品日产第一区二区| 亚洲自拍偷拍一区| 亚洲欧美精品伊人久久| 免费中文日韩| 国产午夜精品全部视频播放| 你懂的国产精品永久在线| 亚洲欧美中日韩| 午夜精品区一区二区三| 性欧美xxxx视频在线观看| 久久黄色网页| 欧美一乱一性一交一视频| 亚洲男女自偷自拍| 久久国产精品网站| 欧美电影免费观看高清| 亚洲国产精品欧美一二99| 日韩视频在线永久播放| 午夜精品999| 久热成人在线视频| 国产精品久久97| 久久久久久久欧美精品| 国产美女精品一区二区三区| 精品96久久久久久中文字幕无| 亚洲片在线观看| 国产精品久久久久久久久久直播| 国产日本欧美一区二区三区| 亚洲国产婷婷香蕉久久久久久99| 亚洲一区二区三区欧美 | 欧美日韩一区二区三区高清| 国产精品久久久久久久午夜片 | 伊人久久婷婷色综合98网| 亚洲片国产一区一级在线观看| 午夜亚洲视频| 亚洲国产精品v| 午夜精品www| 欧美日韩中文在线观看| 依依成人综合视频| 性欧美在线看片a免费观看| 亚洲国产视频直播| 久久久噜噜噜久久中文字免| 国产精品天美传媒入口| 亚洲视频在线免费观看| 国际精品欧美精品| 亚洲精品男同| 欧美88av| 久久免费视频观看| 国产一区美女| 久久国产乱子精品免费女| 亚洲图片欧美日产| 欧美国产三级| 久久久一区二区| 国产精品最新自拍| 亚洲主播在线| 亚洲调教视频在线观看| 欧美日韩亚洲国产一区| 亚洲精品日本| 亚洲成人在线视频网站| 另类激情亚洲| 精品粉嫩aⅴ一区二区三区四区| 午夜久久久久| 亚洲综合视频一区| 国产精品一区一区三区| 午夜精品久久久久久久男人的天堂| 欧美视频在线一区| 国产中文一区| 欧美大片免费久久精品三p | 欧美一区二区视频在线观看2020 | 久久九九国产精品| 欧美日本亚洲视频| 99热在线精品观看| 久久免费国产| 老色批av在线精品| 9i看片成人免费高清| 欧美国产精品va在线观看| 国产欧美一区二区三区在线老狼| 激情欧美一区| 中文一区在线| 亚洲永久免费观看| 欧美暴力喷水在线| 亚洲电影自拍| 91久久久亚洲精品| 久久久久久久久岛国免费| 国产精品嫩草99a| 一区二区免费在线播放| 久久久国产精彩视频美女艺术照福利| 日韩亚洲欧美一区| 欧美激情aaaa| 亚洲伊人观看| 午夜久久电影网| 亚洲二区免费| 一本色道久久综合亚洲精品不卡| 国产精品久久久久高潮| 久久婷婷激情| 亚洲一级黄色| 亚洲精选大片| 亚洲欧美日韩网| 亚洲欧美乱综合| 欧美午夜在线观看| 亚洲精品久久久久久久久久久久久 | 久久天天综合| 老司机精品视频网站| 欧美巨乳波霸| 久久精品国产亚洲一区二区三区| 欧美96在线丨欧| 欧美一区二区黄色| 欧美精品少妇一区二区三区| 亚洲精品视频在线播放| 国产精品99久久久久久人| 亚洲一级网站| 久久久久久久国产| 欧美亚洲网站| 欧美日韩a区| 欧美成人在线网站| 国产日韩一区二区三区| 一区二区高清视频在线观看| 亚洲国产日韩欧美一区二区三区| 亚洲视频自拍偷拍| 麻豆九一精品爱看视频在线观看免费| 先锋影音一区二区三区| 欧美日韩在线大尺度| 久久久久成人精品| 亚洲性图久久| 亚洲性av在线| 国产亚洲精品福利| 国产一区二区欧美日韩| 亚洲国产99| 国产欧美日韩高清| 免费成人性网站| 久久av最新网址| 一本色道久久综合狠狠躁篇的优点 | 亚洲在线观看免费| 欧美日本不卡高清| 午夜精品久久久久久久白皮肤 | 亚洲精品一区二区三区在线观看| 亚洲欧洲一区二区在线播放| 亚洲精品中文字幕在线| 亚洲免费av电影| 国产精品电影网站| 欧美激情在线| 在线成人欧美| 久久久噜噜噜久久中文字幕色伊伊| 久久精品国产99| 国产一区二区精品| 久久国产免费| 麻豆精品在线播放| **欧美日韩vr在线| 蘑菇福利视频一区播放| 亚洲国产精品一区二区第四页av| 亚洲激情自拍| 欧美另类专区| 日韩视频一区| 亚洲影院色无极综合| 久久一综合视频| 国产精品人人做人人爽人人添| 久久精品一本| 久久九九全国免费精品观看| 亚洲一区二区三区中文字幕| 亚洲天堂网站在线观看视频| 国产精品高潮视频| 久久福利精品| 亚洲无限av看| 国产欧美短视频| 久久免费黄色| 欧美高清在线观看| 中国成人黄色视屏| 国产亚洲一区在线| 欧美成人午夜剧场免费观看| 夜夜嗨av一区二区三区免费区| 欧美在线999| 日韩视频免费观看高清在线视频| 国产精品免费视频xxxx| 午夜精品短视频| 欧美国产日韩在线| 亚洲资源在线观看| 在线精品视频一区二区三四| 欧美日韩在线一区二区三区| 久久成人资源| 一区二区三区高清在线观看| 久久亚洲免费| 欧美视频在线观看一区| 久久这里有精品15一区二区三区| 日韩网站在线观看| 免费高清在线一区| 亚洲欧美国产高清| 99精品欧美一区| 亚洲成人资源| 国产欧美一区二区在线观看| 欧美日韩精品一区二区在线播放| 香蕉免费一区二区三区在线观看 | 1024国产精品| 欧美日韩亚洲视频一区| 久久一区国产| 亚洲免费一在线| 在线一区二区视频| 亚洲理论在线| 亚洲激情六月丁香| 欧美成人高清视频| 久久亚洲不卡|