Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(howto/sockets.po): 翻譯 Binary DataDisconnecting 區塊 #518

Merged
merged 2 commits into from
Aug 9, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 34 additions & 3 deletions howto/sockets.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ 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: 2023-07-19 20:17+0800\n"
"PO-Revision-Date: 2023-08-03 18:11+0800\n"
"Last-Translator: Jay <weijay0804@gmail.com>\n"
"Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-"
"tw)\n"
Expand Down Expand Up @@ -417,7 +417,7 @@ msgstr ""

#: ../../howto/sockets.rst:252
msgid "Binary Data"
msgstr ""
msgstr "二進位資料"

#: ../../howto/sockets.rst:254
msgid ""
Expand All @@ -430,6 +430,13 @@ msgid ""
"little-endian, with the least significant byte first - that same ``1`` would "
"be ``01 00``."
msgstr ""
"使用 socket 傳輸二進位資料完全是可行的。最主要的問題在於不同機器使用不同的二"
"進位資料格式。例如,`網路二進位順序 <https://en.wikipedia.org/wiki/"
"Endianness#Networking>`_ 採用的是「大端序 big-endian」,"
"所以一個值為 ``1`` 的 16 位元整數會表示成兩個 16 進位的位元組 ``00 01``。然而"
"大多數常見的處理器 (x86/AMD64,ARM,RISC-V) 採用的是「小端序 little-"
"endian」,所以相同的 ``1`` 會被表示成 ``01 00``。"
"(譯者注:將一個多位數的低位放在較小的位址處,高位放在較大的位址處,則稱小端序;反之則稱大端序。)"

#: ../../howto/sockets.rst:262
msgid ""
Expand All @@ -439,6 +446,10 @@ msgid ""
"these do nothing, but where the machine is byte-reversed, these swap the "
"bytes around appropriately."
msgstr ""
"Socket 函式庫提供了用於轉換 16 位元和 32 位元整數的函式 - ``ntohl, htonl, "
"ntohs, htons``,其中 \"n\" 表示 *network*,\"h\" 表示 *host*,\"s\" 表示 "
"*short*,\"l\" 表示 *long*。當網路的位元組順序和主機位元組順序相同時,這些函"
"式不會做任何操作,但當主機的位元組順序相反時,這些函式會適當的交換位元組順序。"

#: ../../howto/sockets.rst:268
msgid ""
Expand All @@ -449,10 +460,14 @@ msgid ""
"be 8. Of course, this doesn't fit well with fixed-length messages. "
"Decisions, decisions."
msgstr ""
"在現今的 64 位元機器中,二進位資料的 ASCII 表示通常會比二進位表示要小,這是因"
"為在很多情況下,大多數整數的值為 0 或者 1。例如,字串形式的 ``\"0\"`` 是兩個"
"位元組,而完整的 64 位元整數則是 8 個位元組。當然,這對固定長度的訊息來說不太"
"適合,需要自行決定。"

#: ../../howto/sockets.rst:277
msgid "Disconnecting"
msgstr ""
msgstr "結束連線"

#: ../../howto/sockets.rst:279
msgid ""
Expand All @@ -465,6 +480,12 @@ msgid ""
"same as ``shutdown(); close()``. So in most situations, an explicit "
"``shutdown`` is not needed."
msgstr ""
"嚴格來說,在關閉 socket 前,你應該使用 ``shutdown`` 函式。``shutdown`` 函式是"
"發送給 socket 另一端的一個提醒。根據你傳遞的引數,它可以表示「我不會再發送任"
"何訊息了,但我仍然會持續監聽」,或者是「我不會再繼續監聽了,真讚!」。然而,"
"大多數的 socket 函式庫或程式設計師都習慣忽略這種禮節,因為通常情況下 "
"``close`` 跟 ``shutdown(); close()`` 是一樣的。所以在大多數情況下,不需要再特"
"地使用 ``shutdown`` 了。"

#: ../../howto/sockets.rst:287
msgid ""
Expand All @@ -475,6 +496,11 @@ msgid ""
"complete request. The server sends a reply. If the ``send`` completes "
"successfully then, indeed, the client was still receiving."
msgstr ""
"有效使用 ``shutdown`` 的一種方式是在類似 HTTP 的交換中,用戶端發送請求後,然"
"後使用 ``shutdown(1)``。這告訴伺服器「這個用戶端已經發送完成,但仍可以接"
"收」。伺服器可以通過接收「零位元組」來檢測 \"EOF\"。這樣它就可以確定已經接收到"
"完整的請求。伺服器發送回覆,如果 ``send`` 成功完成,那麼用戶端確實在持續接"
"收。"

#: ../../howto/sockets.rst:294
msgid ""
Expand All @@ -485,6 +511,11 @@ msgid ""
"indefinitely, thinking you're just being slow. *Please* ``close`` your "
"sockets when you're done."
msgstr ""
"Python 更進一步地採取自動關閉的步驟,並且當 socket 被垃圾回收機制回收時,如果需要"
"的話,他會自動執行 ``close``。但依賴這個機制是一個非常不好的習慣,如果你的 "
"socket 在沒有 ``close`` 的情況下消失了,那麼另一端的 socket 可能會認為你只是"
"慢了一步,而無期限的等待。*請務必* \\在使用完畢後使用 ``close`` 關閉你的 "
"sockets。"

#: ../../howto/sockets.rst:302
msgid "When Sockets Die"
Expand Down