Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite1b3c52

Browse files
authored
docs(howto/sockets.po): 翻譯Binary DataDisconnecting 區塊 (#518)
* docs(howto/sockets.po): 翻譯 `Binary Data` 和 `Disconnecting` 區塊gh-466* docs(howto/sockets.po): 修改 文法、專有名詞gh-466
1 parent7474386 commite1b3c52

File tree

1 file changed

+34
-3
lines changed

1 file changed

+34
-3
lines changed

‎howto/sockets.po

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ msgstr ""
88
"Project-Id-Version:Python 3.11\n"
99
"Report-Msgid-Bugs-To:\n"
1010
"POT-Creation-Date:2022-06-10 00:16+0000\n"
11-
"PO-Revision-Date:2023-07-19 20:17+0800\n"
11+
"PO-Revision-Date:2023-08-03 18:11+0800\n"
1212
"Last-Translator:Jay <weijay0804@gmail.com>\n"
1313
"Language-Team:Chinese - TAIWAN (https://github.com/python/python-docs-zh-"
1414
"tw)\n"
@@ -417,7 +417,7 @@ msgstr ""
417417

418418
#:../../howto/sockets.rst:252
419419
msgid"Binary Data"
420-
msgstr""
420+
msgstr"二進位資料"
421421

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

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

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

453468
#:../../howto/sockets.rst:277
454469
msgid"Disconnecting"
455-
msgstr""
470+
msgstr"結束連線"
456471

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

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

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

489520
#:../../howto/sockets.rst:302
490521
msgid"When Sockets Die"

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp