[lang_zh]APUE 第二版出來了,由 Stephen A. Rago 改版。[/lang_zh]
[lang_en]APUE 2nd Ed. comes out! Revised by Stephen A. Rago.[/lang_en]
http://books.slashdot.org/books/05/07/09/2258248.shtml?tid=156&tid=130&tid=6
2005年7月13日 星期三
2005年4月18日 星期一
忘了一件事
[lang_zh]
二十歲生日那年,決定在每年生日買給自己一本書,不同領域的書。今年那時候好像在忙什麼事,沒去買,得找個時間去找本書。
我想找一本小說,描寫一個人的小說。
[/lang_zh]
[lang_en]
On my 20th birthday, I made my mind to buy me a book as a present in my every birthdays, something different to my field. I was busy at that time on this birthday, so I haven't bought it until now. Hmm... I need to find a book quickly.
I like to find a novel, a novel which depict someone normal.
[/lang_en]
二十歲生日那年,決定在每年生日買給自己一本書,不同領域的書。今年那時候好像在忙什麼事,沒去買,得找個時間去找本書。
我想找一本小說,描寫一個人的小說。
[/lang_zh]
[lang_en]
On my 20th birthday, I made my mind to buy me a book as a present in my every birthdays, something different to my field. I was busy at that time on this birthday, so I haven't bought it until now. Hmm... I need to find a book quickly.
I like to find a novel, a novel which depict someone normal.
[/lang_en]
2005年4月3日 星期日
TIME_WAIT state
[lang_zh]
在寫計網作業時,發現只要有 client 連進來,在 httpd 砍掉之後,沒辦法馬上再 bind 同一個 port。netstat 看到了 TIME_WAIT。
Active close 一個 connection 時,必須在 TIME_WAIT state 等待 2 x MSL (/maximum segment lifetime/) 的時間。RFC 1122 的建議值是 120 秒。但是 Linux 的實作上 follow BSD,把 MSL 設為 30 秒,net/ipv4/tcp_minisocks.c 裡面有這段註解:
[/lang_zh]
[lang_en]
When I wrote my Computer Network's homework, I found that binding to the same port will be failed after a client comes in and stop the httpd. I see TIME_WAIT state when execute netstat.
One should wait in TIME_WAIT state for 2 x MSL (/maximum segment lifetime/) after close one connection. The suggestion time interval in RFC 1122 is 120 seconds. But the implementation of Linux follows BSD, which set MSL to 30 seconds. There's a comment in net/ipv4/tcp_minisocks.c:
[/lang_en]
[lang_zh]
試了一下時間,真的是一分鐘 Q_Q 本來是在做測試,懶得把 port 寫在參數裡面。看來得辛苦一點點啦 XD
BTW, Unix Network Programming 真是好書呀!!
Update:
用 setsockopt 打開 SO_REUSEADDR 可以解決這個問題
[/lang_zh]
[lang_en]
I observed the time, and it really about 1 minute Q_Q So I should add a port to the argument :/
BTW, Unix Network Programming is really a great book!
Update:
Use setsockopt to enable SO_REUSEADDR will solve this problem.
[/lang_en]
在寫計網作業時,發現只要有 client 連進來,在 httpd 砍掉之後,沒辦法馬上再 bind 同一個 port。netstat 看到了 TIME_WAIT。
Active close 一個 connection 時,必須在 TIME_WAIT state 等待 2 x MSL (/maximum segment lifetime/) 的時間。RFC 1122 的建議值是 120 秒。但是 Linux 的實作上 follow BSD,把 MSL 設為 30 秒,net/ipv4/tcp_minisocks.c 裡面有這段註解:
[/lang_zh]
[lang_en]
When I wrote my Computer Network's homework, I found that binding to the same port will be failed after a client comes in and stop the httpd. I see TIME_WAIT state when execute netstat.
One should wait in TIME_WAIT state for 2 x MSL (/maximum segment lifetime/) after close one connection. The suggestion time interval in RFC 1122 is 120 seconds. But the implementation of Linux follows BSD, which set MSL to 30 seconds. There's a comment in net/ipv4/tcp_minisocks.c:
[/lang_en]
* [ BTW Linux. following BSD, violates this requirement waiting
* only for 60sec, we should wait at least for 240 secs.
* Well, 240 consumes too much of resources 8)
* ]
[lang_zh]
試了一下時間,真的是一分鐘 Q_Q 本來是在做測試,懶得把 port 寫在參數裡面。看來得辛苦一點點啦 XD
BTW, Unix Network Programming 真是好書呀!!
Update:
用 setsockopt 打開 SO_REUSEADDR 可以解決這個問題
[/lang_zh]
[lang_en]
I observed the time, and it really about 1 minute Q_Q So I should add a port to the argument :/
BTW, Unix Network Programming is really a great book!
Update:
Use setsockopt to enable SO_REUSEADDR will solve this problem.
[/lang_en]
訂閱:
文章 (Atom)