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

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

常用鏈接

留言簿(1)

隨筆檔案

文章分類

搜索

  •  

積分與排名

  • 積分 - 33128
  • 排名 - 615

最新評(píng)論

閱讀排行榜

評(píng)論排行榜

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

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.一個(gè)未完成連接的隊(duì)列,此隊(duì)列維護(hù)著那些已收到了客戶端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.一個(gè)已完成的連接的隊(duì)列,此隊(duì)列包含了那些已經(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ù)歷史上被定義為上面兩個(gè)隊(duì)列的大小之和

Berkeley-derived implementations add a fudge factor to the backlog: It is multiplied by 1.5
Berkely實(shí)現(xiàn)中的backlog值為上面兩隊(duì)列之和再乘以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.)
當(dāng)客戶端的第一個(gè)SYN到達(dá)的時(shí)候,TCP會(huì)在未完成隊(duì)列中增加一個(gè)新的記錄然后回復(fù)給客戶端三路握手中的第二個(gè)分節(jié)(服務(wù)端的SYN和針對(duì)客戶端的ACK),這條記錄會(huì)在未完成隊(duì)列中一直存在,直到三路握手中的最后一個(gè)分節(jié)到達(dá),或者直到超時(shí)(Berkeley時(shí)間將這個(gè)超時(shí)定義為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."
如果當(dāng)客戶端SYN到達(dá)的時(shí)候隊(duì)列已滿,TCP將會(huì)忽略后續(xù)到達(dá)的SYN,但是不會(huì)給客戶端發(fā)送RST信息,因?yàn)榇藭r(shí)允許客戶端重傳SYN分節(jié),如果返回錯(cuò)誤信息,那么客戶端將無(wú)法分清到底是服務(wù)端對(duì)應(yīng)端口上沒(méi)有相應(yīng)應(yīng)用程序還是服務(wù)端對(duì)應(yīng)端口上隊(duì)列已滿這兩種情況

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

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

#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) | 評(píng)論 (4)編輯 收藏
boost的線程庫(kù)不能強(qiáng)行終止,所以通過(guò)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; //這里加個(gè)break就結(jié)束了
20         } else {
21             cout << "沒(méi)有等待到通知" << endl;
22         }
23 
24     }
25 }
26 
27 int main() {
28 
29     boost::thread test_thread(test);
30 
31     for (;;) {
32         ::system("PAUSE");
33         cout << "開(kāi)始發(fā)送通知" << endl;
34         test_condition.notify_one();
35     }
36 
37 }

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

實(shí)現(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_;

//獨(dú)占鎖定
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 就可以應(yīng)用這種RAII風(fēng)格的共享鎖實(shí)

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

 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 /// 這個(gè)是輔助類,能夠保證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) | 評(píng)論 (0)編輯 收藏

1、安裝stlport,參考文章:http://www.cnblogs.com/DonLiang/archive/2007/10/13/923143.html
如果是DEBUG模式請(qǐng)?jiān)陧?xiàng)目的屬性=>配置屬性=>c/c++=>命令行的附加選項(xiàng)增加/D_STLP_DEBUG

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

3、修改配置文件boost_1_37_0\tools\build\v2\user-config.jam,將兩個(gè)stlport選項(xiàng)打開(kāi)

4、vs2005命令提示下編譯命令:bjam stdlib=stlport --build-type=complete install,接下來(lái)是漫長(zhǎng)的等待,大概兩個(gè)小時(shí)以上吧

posted @ 2008-12-09 13:22 許海斌 閱讀(1994) | 評(píng)論 (0)編輯 收藏
僅列出標(biāo)題  
青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <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>
            欧美色大人视频| 欧美精品在线观看| 欧美一区二区三区免费观看视频 | 在线综合亚洲欧美在线视频| 亚洲国产成人久久综合| 麻豆精品视频在线| a4yy欧美一区二区三区| 日韩亚洲视频在线| 国产精品日韩欧美综合| 欧美日本在线视频| 久久成人精品| 欧美日韩成人在线观看| 久久深夜福利免费观看| 免费在线一区二区| 久久久精品日韩| 亚洲少妇诱惑| 久久五月天婷婷| 亚洲男人的天堂在线| 欧美成人国产va精品日本一级| 性做久久久久久久久| 老妇喷水一区二区三区| 欧美中文在线免费| 久久看片网站| 久久久久亚洲综合| 欧美精品色网| 免费成人黄色片| 国产精品美女999| 亚洲黄色有码视频| 国产一区二区三区最好精华液| 亚洲国产一区二区视频| 国产亚洲精品久久久久婷婷瑜伽| 国产午夜精品视频免费不卡69堂| 亚洲美女中文字幕| 亚洲最新视频在线播放| 欧美日韩国产不卡在线看| 亚洲国产精品一区二区第一页| 亚洲区第一页| 欧美三级不卡| 亚洲欧美日韩在线观看a三区| 亚洲欧美成人网| 伊人久久亚洲热| 欧美激情精品久久久久久蜜臀 | 亚洲国产成人tv| 黄色综合网站| 久久久五月婷婷| 久久久天天操| 91久久国产综合久久91精品网站| 欧美成年人视频网站| 亚洲欧洲一区二区在线播放| 久久成年人视频| 蜜桃久久精品乱码一区二区| 99视频精品全部免费在线| 国产精品九九| 久久久精品国产免大香伊| 欧美激情第9页| 99国产欧美久久久精品| 国产精品hd| 免费的成人av| 欧美一区二区高清| 欧美国产乱视频| 中文一区二区| 一区二区三区亚洲| 国产欧美在线| 欧美日韩在线播放| 久久久综合激的五月天| 亚洲欧美日韩综合| 欧美成人久久| 久久久噜噜噜久久人人看| 亚洲欧美国产日韩天堂区| 影院欧美亚洲| 国产一区亚洲一区| 国产精品乱码一区二三区小蝌蚪| 麻豆国产va免费精品高清在线| 亚洲在线黄色| 亚洲欧美激情一区二区| 一区二区三区日韩精品视频| 欧美激情中文不卡| 蜜桃精品久久久久久久免费影院| 巨乳诱惑日韩免费av| 99热在这里有精品免费| 亚洲欧美在线x视频| 99成人在线| 国产精品99久久不卡二区| 亚洲精品一区二区三区婷婷月| 在线观看中文字幕亚洲| 裸体一区二区| 91久久国产精品91久久性色| 一区免费观看| 一区二区亚洲精品| 亚洲精品字幕| 性一交一乱一区二区洋洋av| 久久久国产精品一区| 欧美高清在线| 亚洲伊人网站| 久久精品一区二区国产| 欧美ed2k| 国产午夜精品久久久| 在线亚洲欧美视频| 欧美大片在线观看| 日韩亚洲欧美中文三级| 久久国产日韩欧美| 欧美久久在线| 亚洲区一区二| 久久美女性网| 亚洲欧美电影院| 欧美精品在线一区| 亚洲第一成人在线| 久久久久国产一区二区三区四区| 亚洲国产成人av好男人在线观看| 99视频精品在线| 久久夜色精品国产噜噜av| 欧美天堂亚洲电影院在线观看| 国产九区一区在线| 91久久在线观看| 免费中文日韩| 久久精品一区四区| 欧美日韩天天操| 一区二区三区日韩欧美精品| 欧美1级日本1级| 久久婷婷av| 亚洲激情av在线| 亚洲韩日在线| 久久aⅴ国产欧美74aaa| 国产一区免费视频| 久久国产日本精品| 久久成人18免费观看| 雨宫琴音一区二区在线| 久久综合九色综合欧美就去吻 | 免费看精品久久片| 久久成人亚洲| 亚洲韩国一区二区三区| 欧美福利一区二区| 欧美国产日本在线| 日韩一区二区电影网| 一本久久a久久免费精品不卡| 国产精品video| 午夜精品成人在线| 亚洲女同在线| 一区二区三区在线高清| 亚洲三级免费观看| 国产日韩欧美中文| 欧美 日韩 国产 一区| 欧美日韩视频在线第一区| 久久一区二区三区av| 欧美成人亚洲成人| 久久国产精品毛片| 欧美成人有码| 久久精品国产精品亚洲精品| 欧美国产一区二区| 亚洲一级影院| 欧美在线关看| 欧美一区日韩一区| 欧美日韩精品一区二区三区四区| 久久久久久久999精品视频| 欧美精品在线视频| 亚洲电影在线看| 香蕉久久夜色精品国产使用方法 | 欧美三区在线视频| 亚洲第一中文字幕| 激情综合五月天| 欧美呦呦网站| 亚洲久久成人| 欧美精品在线网站| 夜夜嗨av一区二区三区四季av| 亚洲福利视频网站| 欧美大片一区二区三区| 麻豆精品精华液| 黄色成人在线免费| 久久天天狠狠| 狠狠色丁香婷婷综合久久片| 午夜激情久久久| 久久国产日韩欧美| 国产区二精品视| 久久午夜国产精品| 国内一区二区三区在线视频| 欧美成人亚洲成人| 亚洲乱码久久| 国产精品v日韩精品| 亚洲香蕉伊综合在人在线视看| 亚洲欧美日韩人成在线播放| 国产精品一区视频| 免费欧美在线| 午夜精品视频| 亚洲日韩成人| 欧美激情一区二区在线| 久久麻豆一区二区| 亚洲精品影视| 国产精品v一区二区三区| 国内精品视频在线观看| 久久久久久久久久久久久久一区| 美女黄毛**国产精品啪啪| 一区二区三区**美女毛片| 韩国精品主播一区二区在线观看| 欧美日韩国产色视频| 亚洲电影天堂av| 老司机67194精品线观看| 欧美在线精品免播放器视频| 久久久噜噜噜久噜久久| 午夜精品亚洲一区二区三区嫩草| 欧美成人按摩|