Skip to content

Commit

Permalink
docs(howto/sockets.po): 翻譯 sockets.rst:5 到 sockets.rst:106 區塊 (#471)
Browse files Browse the repository at this point in the history
* docs(howto/sockets.po): 翻譯 sockets.rst:5 到 sockets.rst:106 區塊

gh-466

* docs(howto/sockets.po): 去除不必要的空白

gh-466

* docs(howto/sockets.po): 修改名詞、文法

修改成更適合的名詞、文法,標點符號

gh-466

---------

Co-authored-by: Wei-Hsiang (Matt) Wang <[email protected]>
  • Loading branch information
weijay0804 and mattwang44 authored Jul 13, 2023
1 parent ca1538f commit 5a62e2c
Showing 1 changed file with 62 additions and 5 deletions.
67 changes: 62 additions & 5 deletions howto/sockets.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,20 @@ msgstr ""
"Project-Id-Version: Python 3.11\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-06-10 00:16+0000\n"
"PO-Revision-Date: 2018-05-23 14:37+0000\n"
"Last-Translator: Adrian Liaw <adrianliaw2000@gmail.com>\n"
"PO-Revision-Date: 2023-07-12 02:22+0800\n"
"Last-Translator: Jay <weijay0804@gmail.com>\n"
"Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-"
"tw)\n"
"Language: zh_TW\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=1; plural=0;\n"
"X-Generator: Poedit 3.3.2\n"

#: ../../howto/sockets.rst:5
msgid "Socket Programming HOWTO"
msgstr ""
msgstr "Socket 程式設計指南"

#: ../../howto/sockets.rst:0
msgid "Author"
Expand All @@ -43,6 +44,10 @@ msgid ""
"a lot of them), but I hope it will give you enough background to begin using "
"them decently."
msgstr ""
"Sockets 在各處都被廣泛使用,但卻是一項被誤解最嚴重的技術之一。這是一篇對 "
"sockets 的概論介紹。這並不是一個完整的教學指南 - 你還需要做許多準備才能讓 "
"sockets 正常運作。這篇文章也沒有包含細節(其中有非常多的細節),但我希望這篇"
"文章能夠讓你有足夠的背景知識,以便開始正確的使用 sockets 程式設計。"

#: ../../howto/sockets.rst:20
msgid "Sockets"
Expand All @@ -59,6 +64,13 @@ msgid ""
"blocking sockets. But I'll start by talking about blocking sockets. You'll "
"need to know how they work before dealing with non-blocking sockets."
msgstr ""
"我只會討論關於 INET(例如:IPv4)的 sockets,但它們涵蓋了幾乎 99% 的 "
"sockets 使用場景。而我也將僅討論關於 STREAM(比如:TCP)類型的 sockets - 除"
"非你真的知道你在做什麼(在這種情況下,這份指南可能不適合你),使用 STREAM "
"類型的 socket 會獲得比其他 sockets 類型更好的表現和性能。我將會嘗試解釋 "
"socket 是什麼,以及如何使用阻塞 (blocking) 和非阻塞 (non-blocking) sockets 的"
"一些建議。但首先我會先談論阻塞 sockets。在處理非阻塞 sockets 之前,你需要了解"
"它們的工作原理。"

#: ../../howto/sockets.rst:31
msgid ""
Expand All @@ -70,10 +82,16 @@ msgid ""
"sockets exclusively; the web server it's talking to uses both \"server\" "
"sockets and \"client\" sockets."
msgstr ""
"要理解這些東西的困難點之一在於 \"scoket\" 可以代表多種具有些微差異的東西,這主要"
"取決於上下文。所以首先,讓我們先區分「用戶端 (client)」socket 和「伺服器端"
" (server)」socket 的差別,「用戶端」socket 表示通訊的一端,「伺服器端」"
"socket 更像是一個電話總機接線員。用戶端應用程式(例如:你的瀏覽器)只能使"
"用「用戶端」socket; 它所連接的網路伺服器則同時使用「伺服器端」socket 和 "
"「用戶端」socket 來進行通訊。"

#: ../../howto/sockets.rst:40
msgid "History"
msgstr ""
msgstr "歷史"

#: ../../howto/sockets.rst:42
msgid ""
Expand All @@ -82,6 +100,9 @@ msgid ""
"other forms of IPC that are faster, but for cross-platform communication, "
"sockets are about the only game in town."
msgstr ""
"在各種形式的 :abbr:`IPC (Inter Process Communication)` 中,sockets 是最受歡迎"
"的。在任何特定的平台上,可能會存在其他更快速的 IPC 形式,但對於跨平台通訊來"
"說,sockets 是唯一的選擇。"

#: ../../howto/sockets.rst:47
msgid ""
Expand All @@ -90,16 +111,22 @@ msgid ""
"of sockets with INET makes talking to arbitrary machines around the world "
"unbelievably easy (at least compared to other schemes)."
msgstr ""
"Sockets 作為 Unix 的 BSD 分支的一部分在 Berkeley 被發明出來。它們隨著網際網路的普"
"及而迅速蔓延開來。這是有很好的理由 — sockets 和 INET 的結合讓世界各地任何"
"的機器之間的通訊變得非常簡單(至少與其它方案相比是如此)。"

#: ../../howto/sockets.rst:54
msgid "Creating a Socket"
msgstr ""
msgstr "建立一個 Socket"

#: ../../howto/sockets.rst:56
msgid ""
"Roughly speaking, when you clicked on the link that brought you to this "
"page, your browser did something like the following::"
msgstr ""
"大致上來說,當你點擊了帶你來到這個頁面的連結時,你的瀏覽器做了以下的操作:\n"
"\n"
"::"

#: ../../howto/sockets.rst:64
msgid ""
Expand All @@ -108,12 +135,19 @@ msgid ""
"then be destroyed. That's right, destroyed. Client sockets are normally only "
"used for one exchange (or a small set of sequential exchanges)."
msgstr ""
"當 ``connect`` 完成時,這個 socket ``s`` 可以用來發送請求來取得頁面的文本。同"
"一個 socket 也會讀取回傳值,然後再被銷毀。是的,會被銷毀。用戶端 socket 通常只"
"用來做一次交換(或是一小組連續交換)。"

#: ../../howto/sockets.rst:70
msgid ""
"What happens in the web server is a bit more complex. First, the web server "
"creates a \"server socket\"::"
msgstr ""
"網路伺服器 (web server) 的運作就稍微複雜一點。首先,網路伺服器會建立一個「伺服器端 "
"socket」:\n"
"\n"
"::"

#: ../../howto/sockets.rst:80
msgid ""
Expand All @@ -124,13 +158,19 @@ msgid ""
"machine. ``s.bind(('', 80))`` specifies that the socket is reachable by any "
"address the machine happens to have."
msgstr ""
"有幾件事需要注意:我們使用了 ``socket.gethostname()``,這樣 socket 才能對外"
"部網路可見。如果我們使用了 ``s.bind(('localhost', 80))`` 或 ``s."
"bind(('127.0.0.1', 80))``,我們會得到一個「伺服器端」socket,但是只能在同一"
"台機器內可見。``s.bind(('', 80))`` 指定 socket 可以透過機器的任何地址存取。"

#: ../../howto/sockets.rst:87
msgid ""
"A second thing to note: low number ports are usually reserved for \"well "
"known\" services (HTTP, SNMP etc). If you're playing around, use a nice high "
"number (4 digits)."
msgstr ""
"第二個要注意的是:數字小的連接埠 (port) 通常保留給「廣為人知的」服務(HTTP、SNMP"
"等)。如果你只是想執行程式,可以使用一個數字較大的連接埠(4 位數字)。"

#: ../../howto/sockets.rst:91
msgid ""
Expand All @@ -139,12 +179,19 @@ msgid ""
"outside connections. If the rest of the code is written properly, that "
"should be plenty."
msgstr ""
"最後,``listen`` 引數告訴 socket 函式庫 (library),我們希望在佇列 (queue) 中"
"累積達 5 個(正常的最大值)連接請求後再拒絕外部連接。如果其餘的程式碼編寫"
"正確,這應該足夠了。"

#: ../../howto/sockets.rst:95
msgid ""
"Now that we have a \"server\" socket, listening on port 80, we can enter the "
"mainloop of the web server::"
msgstr ""
"現在我們有一個監聽 80 連接埠的「伺服器端」socket 了,我們可以進入網路伺服器的"
"主迴圈了:\n"
"\n"
"::"

#: ../../howto/sockets.rst:106
msgid ""
Expand All @@ -161,6 +208,16 @@ msgid ""
"The two \"clients\" are free to chat it up - they are using some dynamically "
"allocated port which will be recycled when the conversation ends."
msgstr ""
"事實上,有三種方法可以讓這個迴圈運作 - 分配一個執行緒 (thread) 來處理 "
"``clientsocket`` 、建立一個新行程 (process) 來處理 ``clientsocket``,或者將"
"這個程式重新改寫成使用非阻塞 socket,並使用 ``select`` 在我們的「伺服器端」"
"socket 和任何有效的 ``clientsocket`` 之間進行多工處理。稍後將會更詳細的介紹。"
"現在最重要的是理解:這就是「伺服器端」socket 做的\\ *所有* \\事情。它不會發送任何"
"資料、也不接收任何資料,它只會建立「伺服器端」socket。每個 ``clientsocket`` "
"都是為了回應某些\\ *其他* \\ ``connect()`` 到我們綁定的主機上的「用戶端」socket。"
"一但 ``clientsocket`` 建立完成,就會繼續監聽更多的連接請求。兩個「用戶端」可"
"以隨意的通訊 - 它們使用的是一些動態分配的連接埠,會在通訊結束的時候被回收並重新"
"利用。"

#: ../../howto/sockets.rst:121
msgid "IPC"
Expand Down

0 comments on commit 5a62e2c

Please sign in to comment.