-
-
Notifications
You must be signed in to change notification settings - Fork 38
Expand file tree
/
Copy pathsockets.po
More file actions
768 lines (707 loc) ยท 42.8 KB
/
Copy pathsockets.po
File metadata and controls
768 lines (707 loc) ยท 42.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
# SOME DESCRIPTIVE TITLE.
# Copyright (C) 2001 Python Software Foundation
# This file is distributed under the same license as the Python package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
# Translators:
# python-doc bot, 2025
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: Python 3.15\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2026-09-01 17:31+0000\n"
"PO-Revision-Date: 2025-09-16 00:00+0000\n"
"Last-Translator: python-doc bot, 2025\n"
"Language-Team: Japanese (https://app.transifex.com/python-doc/teams/5390/"
"ja/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Language: ja\n"
"Plural-Forms: nplurals=1; plural=0;\n"
#: ../../howto/sockets.rst:5
msgid "Socket Programming HOWTO"
msgstr "ใฝใฑใใใใญใฐใฉใใณใฐ HOWTO"
#: ../../howto/sockets.rst-1
msgid "Abstract"
msgstr "ๆฆ่ฆ"
#: ../../howto/sockets.rst:9
msgid ""
"Sockets are used nearly everywhere, but are one of the most severely "
"misunderstood technologies around. This is a 10,000 foot overview of "
"sockets. It's not really a tutorial - you'll still have work to do in "
"getting things operational. It doesn't cover the fine points (and there are "
"a lot of them), but I hope it will give you enough background to begin using "
"them decently."
msgstr ""
"ใฝใฑใใใฏใใใใใใงไฝฟใใใฆใใใใๆๅคง็ดใซ่ชค่งฃใใใฆใใๆ่กใงใใใใใ"
"ใฎๆๆธใฏใฝใฑใใใฎๅ
จไฝๅใไฟฏ็ฐใใฆใใใใใฅใผใใชใขใซใจใใฆใฏใใพใๅฝนใซ็ซใ"
"ใชใใๅฎ้ใซๅใใขใใๅฎๆใใใใซใฏใไปใซใใใใชใใใฐใใใชใใใจใใใใ"
"ใใ ใใใฎๆๆธใฏใฝใฑใใใฎๅพฎๅฆใชใจใใ (ใใใใใใ) ใพใงใฏใซใใผใใฆใใชใ"
"ใใๆฅใใใใใชใไฝฟใๆนใใงใใใใใซใชใ็จๅบฆใฎๆ
ๅ ฑใฏๅพใใใใฏใใ ใ"
#: ../../howto/sockets.rst:17
msgid "Sockets"
msgstr "ใฝใฑใใ"
#: ../../howto/sockets.rst:19
msgid ""
"I'm only going to talk about INET (i.e. IPv4) sockets, but they account for "
"at least 99% of the sockets in use. And I'll only talk about STREAM (i.e. "
"TCP) sockets - unless you really know what you're doing (in which case this "
"HOWTO isn't for you!), you'll get better behavior and performance from a "
"STREAM socket than anything else. I will try to clear up the mystery of what "
"a socket is, as well as some hints on how to work with blocking and non-"
"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) ใฝใฑใใใฎใใจใใ่ชใใชใใคใใใ ใใๅฉ็จ็ใงใใใจใฝ"
"ใฑใใใฎ 99% ไปฅไธใฏใใใ ใใใใซไธญใงใ STREAM (ใใชใใก TCP) ใฝใฑใใใซ่ฉฑ้ก"
"ใ็ตใใใจๆใ - ่ชๅใไฝใใใฆใใใฎใๅใใฃใฆใใใฎใงใชใ้ใ (ๅใใฃใฆใใช"
"ใใใฎ HOWTO ใชใใฆ่ฆใใชใใ ใ!)ใSTREAM ใฝใฑใใใไธ็ชๅใใใใใใไธ็ชๆง"
"่ฝใๅบใใฎใ ใใใใใฃใฆ่ฌใซๅ
ใพใใใฝใฑใใใฎๆญฃไฝใๆใใใซใใฆใใใจๅ
ฑใซใ"
"ใใญใใญใณใฐใใใณใใณใใญใใญใณใฐใชใฝใฑใใใฎๆฑใใซ้ขใใใใใคใใฎใใณใใ"
"ๆ็คบใใใใใ ใใใพใใฏใใญใใญใณใฐใฝใฑใใใใๅงใใใใจใซใใใใใณใใญใ"
"ใญใณใฐใๆฑใใใๅ
ใซใใใญใใญใณใฐใฎไป็ตใฟใ็ฅใฃใฆใใใชใใฆใฏใชใใชใใฎใ ใ"
#: ../../howto/sockets.rst:28
msgid ""
"Part of the trouble with understanding these things is that \"socket\" can "
"mean a number of subtly different things, depending on context. So first, "
"let's make a distinction between a \"client\" socket - an endpoint of a "
"conversation, and a \"server\" socket, which is more like a switchboard "
"operator. The client application (your browser, for example) uses \"client\" "
"sockets exclusively; the web server it's talking to uses both \"server\" "
"sockets and \"client\" sockets."
msgstr ""
"่ฉฑใ็่งฃใใซใใใใฆใใ่ฆๅ ใจใใฆใใใฝใฑใใใใจใใ่จ่ใๆ่ใซใใฃใฆๅพฎๅฆ"
"ใซ้ใใใฎใๆใใใจใๆใใใใใใใใงใพใใใใฏใฉใคใขใณใใใฝใฑใใ - ๅฏพ่ฉฑ"
"ใฎไธก็ซฏ - ใจใใตใผใใใฝใฑใใ - ้ป่ฉฑไบคๆๆใฟใใใชใใฎ - ใฎๅบๅฅใไปใใฆใใ"
"ใใใฏใฉใคใขใณใใขใใชใฑใผใทใงใณ (ใใจใใฐใใฉใฆใถ) ใฏใใฏใฉใคใขใณใใใฝใฑใ"
"ใใ ใใไฝฟใใใ่ฉฑใ็ธๆใฎใฆใงใใตใผใใฏใใตใผใใใฝใฑใใใจใใฏใฉใคใขใณใใ"
"ใฝใฑใใใฎไธกๆนใไฝฟใใ"
#: ../../howto/sockets.rst:37
msgid "History"
msgstr "ๆญดๅฒ"
#: ../../howto/sockets.rst:39
msgid ""
"Of the various forms of :abbr:`IPC (Inter Process Communication)`, sockets "
"are by far the most popular. On any given platform, there are likely to be "
"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` (ใใญใปใน้้ไฟก) ใฎไธญใงใใใฝ"
"ใฑใใใฏ็พคใๆใใฆไบบๆฐใใใใใฉใฎใใฉใใใใฉใผใ ใซใใใฝใฑใใใใ้ใ IPC "
"ใฏใใใ ใใใใ ใใใใฉใใใใฉใผใ ใใพใใ้ไฟกใฏใฝใฑใใใฎ็ฌๆ
ๅ ดใ ใ"
#: ../../howto/sockets.rst:44
msgid ""
"They were invented in Berkeley as part of the BSD flavor of Unix. They "
"spread like wildfire with the internet. With good reason --- the combination "
"of sockets with INET makes talking to arbitrary machines around the world "
"unbelievably easy (at least compared to other schemes)."
msgstr ""
"ใฝใฑใใใฏ BSD Unix ใฎไธ้จใจใใฆใใผใฏใฌใคใง็บๆใใใใคใณใฟใผใใใใฎๆฎๅใจ"
"ๅ
ฑใซ้็ซใฎใใจใๅบใพใฃใใใใใใใฃใจใใชใใจใงใใฝใฑใใใจ INET ใฎใณใณใใซ"
"ใใฃใฆไธ็ไธญใฉใใชใใทใณใจใใไฟกใใใใชใใปใฉ็ฐกๅ (ๅฐใชใใจใไปใฎในใญใผใ ใจ"
"ๆฏในใฆ) ใซ้ไฟกใงใใใใใซใชใฃใใฎใ ใ"
#: ../../howto/sockets.rst:51
msgid "Creating a Socket"
msgstr "ใฝใฑใใใฎไฝๆ"
#: ../../howto/sockets.rst:53
msgid ""
"Roughly speaking, when you clicked on the link that brought you to this "
"page, your browser did something like the following::"
msgstr ""
"ใใชใใใชใณใฏใใฏใชใใฏใใฆใใฎใใผใธใซๆฅใใจใใใใฉใฆใถใฏๅคง้ๆใซ่จใฃใฆๆฌก"
"ใฎใใใชใใจใใใใฎใงใใ::"
#: ../../howto/sockets.rst:56
msgid ""
"# create an INET, STREAMing socket\n"
"s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)\n"
"# now connect to the web server on port 80 - the normal http port\n"
"s.connect((\"www.python.org\", 80))"
msgstr ""
#: ../../howto/sockets.rst:61
msgid ""
"When the ``connect`` completes, the socket ``s`` can be used to send in a "
"request for the text of the page. The same socket will read the reply, and "
"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`` ใๅฎไบใใใจใใฝใฑใใ ``s`` ใไฝฟใฃใฆใใฎใใผใธๆ็ซ ใธใฎ่ฆๆฑ"
"ใ้ใใใจใใงใใใใใซใชใใใใฎๅใใฝใฑใใใ่ฟ็ญใ่ชญใฟใใใใฆ็ ดๅฃใใ"
"ใใใใใ็ ดๅฃใใใใใฏใฉใคใขใณใใฝใฑใใใฏ้ๅธธใไธๅ (ใๅฐๆฐใฎ) ใใๅใใง"
"ไฝฟใๆจใฆใซใชใใฎใ ใ"
#: ../../howto/sockets.rst:67
msgid ""
"What happens in the web server is a bit more complex. First, the web server "
"creates a \"server socket\"::"
msgstr ""
"ใฆใงใใตใผใใง่ตทใใไบๆใฏใใๅฐใ่ค้ใ ใใพใใใตใผใใฝใฑใใใใไฝใ::"
#: ../../howto/sockets.rst:70
msgid ""
"# create an INET, STREAMing socket\n"
"serversocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)\n"
"# bind the socket to a public host, and a well-known port\n"
"serversocket.bind((socket.gethostname(), 80))\n"
"# become a server socket\n"
"serversocket.listen(5)"
msgstr ""
#: ../../howto/sockets.rst:77
msgid ""
"A couple things to notice: we used ``socket.gethostname()`` so that the "
"socket would be visible to the outside world. If we had used ``s."
"bind(('localhost', 80))`` or ``s.bind(('127.0.0.1', 80))`` we would still "
"have a \"server\" socket, but one that was only visible within the same "
"machine. ``s.bind(('', 80))`` specifies that the socket is reachable by any "
"address the machine happens to have."
msgstr ""
"ใใใงๆณจๆใในใ็นใใใใคใใใ: ไปๅใฏใฝใฑใใใๅค็ใซ่ฆใใใใใ "
"``socket.gethostname()`` ใไฝฟใฃใใ ``s.bind(('localhost', 80))`` ใ ``s."
"bind(('127.0.0.1', 80))`` ใงใใใตใผใใใฝใฑใใใซใฏใชใใใใใใ ใจๅใใใท"
"ใณๅ
ใซใใ่ฆใใชใใใฎใซใชใฃใฆใใพใใ ``s.bind(('', 80))`` ใฏใใฎใใทใณใ"
"ๆใฃใฆใใๅ
จใฆใฎใขใใฌในใงๆฅ็ถๅฏ่ฝใซใชใใใใซใจใใๆๅฎใซใชใใ"
#: ../../howto/sockets.rst:84
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 ""
"ใตใใคใ: ๅฐใใช็ชๅทใฎใใผใใฏๅคงๆตใใใฆใงใซใใฆใณ (ๆๅ)ใใชใตใผใใน (HTTP, "
"SNMP ็ญใ
) ใฎใใใซๅใฃใฆใใใใ้ใณใงไฝฟใใฎใชใ้ฉๅฝใซๅคงใใชๆฐ (4ๆก) ใไฝฟใ"
"ใใ"
#: ../../howto/sockets.rst:88
msgid ""
"Finally, the argument to ``listen`` tells the socket library that we want it "
"to queue up as many as 5 connect requests (the normal max) before refusing "
"outside connections. If the rest of the code is written properly, that "
"should be plenty."
msgstr ""
"ๆๅพใซ: ``listen`` ใฎๅผๆฐใฏใฝใฑใใใฉใคใใฉใชใซใๆฅ็ถ่ฆๆฑใ 5 ๅ (้ๅธธใฎๆๅคง"
"ๅค) ใพใง้ ็ชๅพ
ใกใใใใใใซๅฝใใฆใใใใใไปฅ้ใฎๅค้จๆฅ็ถใฏๆๅฆใใใฎใ ใใ"
"ใณใผใใ้ฉๅใซๆธใใใฆใใใฐใใใใงๅๅใใใใปใฉใ ใ"
#: ../../howto/sockets.rst:92
msgid ""
"Now that we have a \"server\" socket, listening on port 80, we can enter the "
"mainloop of the web server::"
msgstr ""
"ใใใใใตใผใใผใฝใฑใใใใใงใใฆใ80 ็ชใใผใใง่ณใๆพใพใใฆใใใจใใใพใงๆฅ"
"ใใใงใฏใใฆใงใใตใผใใฎใกใคใณใซใผใใซๅ
ฅใใ::"
#: ../../howto/sockets.rst:95
msgid ""
"while True:\n"
" # accept connections from outside\n"
" (clientsocket, address) = serversocket.accept()\n"
" # now do something with the clientsocket\n"
" # in this case, we'll pretend this is a threaded server\n"
" ct = make_client_thread(clientsocket)\n"
" ct.start()"
msgstr ""
#: ../../howto/sockets.rst:103
msgid ""
"There's actually 3 general ways in which this loop could work - dispatching "
"a thread to handle ``clientsocket``, create a new process to handle "
"``clientsocket``, or restructure this app to use non-blocking sockets, and "
"multiplex between our \"server\" socket and any active ``clientsocket``\\ s "
"using ``select``. More about that later. The important thing to understand "
"now is this: this is *all* a \"server\" socket does. It doesn't send any "
"data. It doesn't receive any data. It just produces \"client\" sockets. Each "
"``clientsocket`` is created in response to some *other* \"client\" socket "
"doing a ``connect()`` to the host and port we're bound to. As soon as we've "
"created that ``clientsocket``, we go back to listening for more connections. "
"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 ""
"ใใฎใซใผใใซใฏๅฎ้ใฎใจใใใ3 ้ใใฎไธ่ฌ็ใชๅไฝๆนๆณใใใ - "
"``clientsocket`` ใๆฑใใใใซในใฌใใใๅฒใๅฝใฆใใใ``clientsocket`` ใๆฑใ"
"ๆฐใใใใญใปในใไฝใฃใใใใใใใฏใใณใใญใใญใณใฐใฝใฑใใใไฝฟใใใใซใขใใช"
"ใไฝใ็ดใใฆ ``select`` ใงใใตใผใใใฝใฑใใใจใขใฏใใฃใใช ``clientsocket`` "
"ใฎ้ใๅค้ๅใใใใใใฎใ ใๆๅพใฎใซใคใใฆใฏใพใๅพใซใใใใใใใง็่งฃใใฆใ"
"ใในใ่ฆ็นใฏใใใ : ไปฅไธใใใตใผใใใฝใฑใใใฎไปไบใฎ *ใในใฆ* ใงใใใใใผใฟ"
"ใฏไธๅ้ไฟกใใชใใใๅไฟกใใชใใใใฏใฉใคใขใณใใใฝใฑใใใ็ใฟๅบใใ ใใๆใ
"
"ใฎใใคใณใใใใฆใใใในใใจใใผใใซ ``connect()`` ใใฆใใ *ไปใฎ* ใใฏใฉใคใข"
"ใณใใใฝใฑใใใซๅฟใใๅฝขใง ``clientsocket`` ใไฝใใไฝใใๅฆใใใใใชใๆฅ็ถ"
"ใ่ใใซๆปใฃใฆใใใฎใ ใใใฎใตใใคใฎใใฏใฉใคใขใณใใใฏใใใจใฏๅๆใซๅใฃใฆใ"
"ใใฐใใ - ไฝฟใใใผใใฏๅ็ใซๅฒใๅฝใฆใใใไผ่ฉฑใ็ตใใใฐใชใตใคใฏใซใซๅปปใใ"
"ใใ"
#: ../../howto/sockets.rst:118
msgid "IPC"
msgstr "IPC"
#: ../../howto/sockets.rst:120
msgid ""
"If you need fast IPC between two processes on one machine, you should look "
"into pipes or shared memory. If you do decide to use AF_INET sockets, bind "
"the \"server\" socket to ``'localhost'``. On most platforms, this will take "
"a shortcut around a couple of layers of network code and be quite a bit "
"faster."
msgstr ""
"1ใคใฎใใทใณไธใฎ2ใใญใปใน้ใง้ซ้ใชIPCใ่กใใใๅ ดๅใฏใpipe ใๅ
ฑๆใกใขใชใๆค"
"่จใใในใใงใใAF_INET ใฝใฑใใใไฝฟ็จใใใจๆฑบใใๅ ดๅใใใตใผใใผใใฝใฑใใ"
"ใฏ ``'localhost'`` ใซใใคใณใใใพใใใใใปใจใใฉใฎใใฉใใใใฉใผใ ใงใใใใค"
"ใใฎใใใใฏใผใฏใฌใคใคใผใใทใงใผใใซใใใใใใจใงใใชใ้ซ้ใซใชใใพใใ"
#: ../../howto/sockets.rst:126
msgid ""
"The :mod:`multiprocessing` integrates cross-platform IPC into a higher-level "
"API."
msgstr ""
":mod:`multiprocessing` ใฏใฏใญในใใฉใใใใฉใผใ ใชIPCใฎ้ซ็ดใชAPIใๆไพใใฆใใพ"
"ใใ"
#: ../../howto/sockets.rst:131
msgid "Using a Socket"
msgstr "ใฝใฑใใใฎๅฉ็จ"
#: ../../howto/sockets.rst:133
msgid ""
"The first thing to note, is that the web browser's \"client\" socket and the "
"web server's \"client\" socket are identical beasts. That is, this is a "
"\"peer to peer\" conversation. Or to put it another way, *as the designer, "
"you will have to decide what the rules of etiquette are for a conversation*. "
"Normally, the ``connect``\\ ing socket starts the conversation, by sending "
"in a request, or perhaps a signon. But that's a design decision - it's not a "
"rule of sockets."
msgstr ""
"ใฏใใใซๆถใใฆใใในใใชใฎใฏใใฆใงใใใฉใฆใถใฎใใฏใฉใคใขใณใใใฝใฑใใใจใฆใง"
"ใใตใผใใฎใใฏใฉใคใขใณใใใฝใฑใใใใพใฃใใๅใ็จฎๆใ ใจใใใใจใ ใใคใพใใ"
"ใใใฏใใใขใปใใฅใปใใขใ(1 ๅฏพ 1) ใฎไผ่ฉฑใงใใใๅฅใฎ่จใๆนใใใใจใ *่จญ่จ่
"
"ใจใใฆ่ชๅใงไผ่ฉฑใฎใจใใฑใใ่ฆๅใๆฑบใใชใใฆใฏใใใชใ* ใจใใใใจใงใใใใ"
"้ๅธธใฏใ ``connect`` ใใฆใใใฝใฑใใใ่ฆๆฑใใใใฏๅฎฃ่จใใใฆไผ่ฉฑใๅงใใใใ "
"ใใใใใฏใใ่จญ่จใใใ ใใฎใใจใ - ใฝใฑใใใฎ่ฆๅใงใฏใชใใ"
#: ../../howto/sockets.rst:140
msgid ""
"Now there are two sets of verbs to use for communication. You can use "
"``send`` and ``recv``, or you can transform your client socket into a file-"
"like beast and use ``read`` and ``write``. The latter is the way Java "
"presents its sockets. I'm not going to talk about it here, except to warn "
"you that you need to use ``flush`` on sockets. These are buffered \"files\", "
"and a common mistake is to ``write`` something, and then ``read`` for a "
"reply. Without a ``flush`` in there, you may wait forever for the reply, "
"because the request may still be in your output buffer."
msgstr ""
"ใใฆใใณใใฅใใฑใผใทใงใณใซไฝฟใๅ่ฉใฏไบ็ตใใใ ``send`` ใจ ``recv`` ใไฝฟใใ"
"ใจใใงใใใใใฏใฉใคใขใณใใฝใฑใใใใใกใคใซใฃใฝใ็จฎๆใซๅคๅฝขใใฆ ``read`` ใจ "
"``write`` ใไฝฟใฃใฆใ่ฏใใๅพ่
ใฏ Java ใฎใฝใฑใใใฎ่กจ็พๆนๆณใ ใใใใง่ฉณใใ่ช"
"ใใคใใใฏใชใใใใใฎๅ ดๅใฏใฝใฑใใใ ``flush`` ใใชใใใฐใใใชใใใจใ ใ"
"่จใฃใฆใใใใใใฏใใใใกใชใณใฐใใใใใกใคใซใใชใฎใงใไฝใใ ``write`` ใใฆ"
"ใใใซ่ฟ็ญใ ``read`` ใใใจใใใฎใฏใใใใ้้ใใ ใ้ใซ ``flush`` ใๅ
ฅใใช"
"ใใจใ่ฆๆฑใใพใ ๅบๅใใใใกใซใใฃใฆๆฐธ้ ใซ่ฟไบใๆฅใชใใใจใใๅฏ่ฝๆงใใใใ"
#: ../../howto/sockets.rst:149
msgid ""
"Now we come to the major stumbling block of sockets - ``send`` and ``recv`` "
"operate on the network buffers. They do not necessarily handle all the bytes "
"you hand them (or expect from them), because their major focus is handling "
"the network buffers. In general, they return when the associated network "
"buffers have been filled (``send``) or emptied (``recv``). They then tell "
"you how many bytes they handled. It is *your* responsibility to call them "
"again until your message has been completely dealt with."
msgstr ""
"ใใใใฝใฑใใใฎไธป่ฆใช้ฃ้ขใซ้ฒใใ - ``send`` ใจ ``recv`` ใฏใใใใฏใผใฏใใ"
"ใใกใซๅใใใใใใฎใ ใใ ใใใๆๆธกใใใใฎ (ใ่ฟใใฆใใใใใใใฎ) ใ 1 ใ"
"ใคใใๆฎใใๅฎ้ใซๅฆ็ใใฆใใใฆใใใจใฏ้ใใชใใไธ่ฌ็ใซ่จใฃใฆใ ``send`` "
"ใฏใใใใกใๅใพใใพใงใ``recv`` ใฏใใใใกใ็ฉบใซใชใใพใงๅฆ็ใใใฆใใใฎใใค"
"ใๆฐใ่ฟใใใกใใปใผใธใๅฎๅ
จใซๅฆ็ใใใใพใง็นฐใ่ฟใๅผใณๅบใใฎใฏ *่ชๅใฎ* ่ฒฌ"
"ไปปใชใฎใ ใ"
#: ../../howto/sockets.rst:157
msgid ""
"When a ``recv`` returns 0 bytes, it means the other side has closed (or is "
"in the process of closing) the connection. You will not receive any more "
"data on this connection. Ever. You may be able to send data successfully; "
"I'll talk more about this later."
msgstr ""
"``recv`` ใ 0 ใใคใใ่ฟใใใจใใฏใๅใใๅดใๆฅ็ถใ้ใใฆใใพใฃใ (ใพใใฏ้"
"ใใใใจใใฆใใ้ไธญ) ใจใใๆๅณใ ใใใใใฎๆฅ็ถใงใใผใฟใๅใๅใใใจใฏใช"
"ใใๆฐธ้ ใซใ ใใใ ใใใผใฟ้ไฟกใฏๆๅใใใใใใใชใ; ใใใซใคใใฆใฏใใจใง่ช"
"ใใใจใซใใใใ"
#: ../../howto/sockets.rst:162
msgid ""
"A protocol like HTTP uses a socket for only one transfer. The client sends a "
"request, then reads a reply. That's it. The socket is discarded. This means "
"that a client can detect the end of the reply by receiving 0 bytes."
msgstr ""
"HTTP ใฎใใใชใใญใใณใซใงใฏใใฒใจใคใฎใฝใฑใใใ1ๅใฎ่ปข้ใซใใไฝฟใใชใใใฏใฉ"
"ใคใขใณใใฏ่ฆๆฑใ้ใใ่ฟ็ญใๅใใใไปฅไธใ ใใใใงใฝใฑใใใฏ็ ดๆฃใใใใใ ใ"
"ใใใฎๅ ดๅใใฏใฉใคใขใณใใฏๅไฟก 0 ใใคใใฎๆ็นใง่ฟ็ญใฎๆซๅฐพใๆคๅบใใใใจใใงใ"
"ใใ"
#: ../../howto/sockets.rst:166
msgid ""
"But if you plan to reuse your socket for further transfers, you need to "
"realize that *there is no* :abbr:`EOT (End of Transfer)` *on a socket.* I "
"repeat: if a socket ``send`` or ``recv`` returns after handling 0 bytes, the "
"connection has been broken. If the connection has *not* been broken, you "
"may wait on a ``recv`` forever, because the socket will *not* tell you that "
"there's nothing more to read (for now). Now if you think about that a bit, "
"you'll come to realize a fundamental truth of sockets: *messages must either "
"be fixed length* (yuck), *or be delimited* (shrug), *or indicate how long "
"they are* (much better), *or end by shutting down the connection*. The "
"choice is entirely yours, (but some ways are righter than others)."
msgstr ""
"ใ ใใไปฅ้ใฎ่ปข้ใซใใใฎใฝใฑใใใไฝฟใๅใใคใใใชใใใฝใฑใใใซ :abbr:`EOT "
"(End of Transfer)` ใชใฉ *ๅญๅจใใชใ* ใใจใ่ช่ญใใๅฟ
่ฆใใใใใใไธๅบฆ่จใ"
"ใ: ใฝใฑใใใฎ ``send`` ใ ``recv`` ใ 0 ใใคใๅฆ็ใง่ฟใฃใฆใใใชใใใใฎๆฅ็ถ"
"ใฏ็ตใใฃใฆใใใ็ตใใฃใฆ *ใใชใ* ใชใใใใคใพใง ``recv`` ใๅพ
ใฆใฐใใใใฏๅ"
"ใใใชใใใฝใฑใใใฏใใใ่ชญใใใฎใ (ไปใฎใจใใ) ใชใใใใชใฉใจ *่จใใชใ* "
"ใฎใ ใใใใใฎใใจใๅฐใ่ใใใฐใใฝใฑใใใฎ็ๅฎใๆใใใจใซใชใใ ใใ: *ใกใ"
"ใปใผใธใฏๅฟ
ใๅบๅฎ้ทใ* (ใใใ) *ๅบๅใๆๅญใไฝฟใใ* (ใใใใ) *้ทใๆจ่ญใไป"
"ใใฆใใใ* (ใใชใใใท) *ๆฅ็ถใ้ใใฆ็ตใใใใใใฎใใใใใงใชใใใฐใใใช"
"ใ* ใฎใ ใ้ธใถๆจฉๅฉใจ่ฒฌไปปใฏใพใฃใใใใฃใฆ่ชๅใซใใ (ใใๆญฃใใใฎ็จๅบฆใซ้ใใฏ"
"ใใ)ใ"
#: ../../howto/sockets.rst:177
msgid ""
"Assuming you don't want to end the connection, the simplest solution is a "
"fixed length message::"
msgstr ""
"ๆฏๅๆฅ็ถใ็ตใใใใใฎใฏใคใคใ ใจใใฆใๆใๅ็ดใช่งฃๆฑบ็ญใฏๅบๅฎ้ทใกใใปใผใธใ ใ"
"ใ::"
#: ../../howto/sockets.rst:180
msgid ""
"class MySocket:\n"
" \"\"\"demonstration class only\n"
" - coded for clarity, not efficiency\n"
" \"\"\"\n"
"\n"
" def __init__(self, sock=None):\n"
" if sock is None:\n"
" self.sock = socket.socket(\n"
" socket.AF_INET, socket.SOCK_STREAM)\n"
" else:\n"
" self.sock = sock\n"
"\n"
" def connect(self, host, port):\n"
" self.sock.connect((host, port))\n"
"\n"
" def mysend(self, msg):\n"
" totalsent = 0\n"
" while totalsent < MSGLEN:\n"
" sent = self.sock.send(msg[totalsent:])\n"
" if sent == 0:\n"
" raise RuntimeError(\"socket connection broken\")\n"
" totalsent = totalsent + sent\n"
"\n"
" def myreceive(self):\n"
" chunks = []\n"
" bytes_recd = 0\n"
" while bytes_recd < MSGLEN:\n"
" chunk = self.sock.recv(min(MSGLEN - bytes_recd, 2048))\n"
" if chunk == b'':\n"
" raise RuntimeError(\"socket connection broken\")\n"
" chunks.append(chunk)\n"
" bytes_recd = bytes_recd + len(chunk)\n"
" return b''.join(chunks)"
msgstr ""
#: ../../howto/sockets.rst:214
msgid ""
"The sending code here is usable for almost any messaging scheme - in Python "
"you send strings, and you can use ``len()`` to determine its length (even if "
"it has embedded ``\\0`` characters). It's mostly the receiving code that "
"gets more complex. (And in C, it's not much worse, except you can't use "
"``strlen`` if the message has embedded ``\\0``\\ s.)"
msgstr ""
"ใใฎ้ไฟกใณใผใใฏใใปใผใใใใใกใใปใผใธ้ไฟกในใญใผใ ใงไฝฟใใ - ๆๅญๅใ้ใใจ"
"ใใPython ใชใ้ทใใ ``len()`` ใง่ฆๆฅตใใใใจใใงใใ (ไธญใซ ``\\0`` ใๅใ่พผ"
"ใพใใฆใใฆใๅคงไธๅคซ)ใ้ฃใใใใฆใใใฎใฏใใใใซๅไฟกใณใผใใงใใใ (ใชใใC ใง"
"ใไบๆ
ใฏใใพใๆชใใชใใชใใใใกใใปใผใธใซ ``\\0`` ใๅใ่พผใพใใฆใใใจ "
"``strlen`` ใไฝฟใใชใใฎใฏ้ขๅใ ใ)"
#: ../../howto/sockets.rst:220
msgid ""
"The easiest enhancement is to make the first character of the message an "
"indicator of message type, and have the type determine the length. Now you "
"have two ``recv``\\ s - the first to get (at least) that first character so "
"you can look up the length, and the second in a loop to get the rest. If you "
"decide to go the delimited route, you'll be receiving in some arbitrary "
"chunk size, (4096 or 8192 is frequently a good match for network buffer "
"sizes), and scanning what you've received for a delimiter."
msgstr ""
"ๆใ็ฐกๅใชๆน่ฏๆณใฏใใกใใปใผใธใฎๆๅใฎไธๆๅญใใฟใคใๆจ่ญใซใใฆใใใฎใฟใคใใง"
"้ทใใๆฑบๅฎใใใจใใใใฎใ ใใใฎๅ ดๅใตใใคใฎ ``recv`` ใใใใใจใซใชใ - ไธ็ช"
"็ฎใงใใฎไธๆๅญ (ใ ใใใใชใใฆใๅฏ) ใๅใฃใฆ้ทใใ่ชฟในใไบ็ช็ฎใงใซใผใใใฆๆฎ"
"ใใๅใใฎใ ใใใใใฏใใๅบๅใๆนๅผใฎ้ใ่กใใฎใงใใใฐใไปปๆใฎใตใคใบ (4096 "
"ใ 8192 ใใใใใฏใผใฏใใใใกใซใฏๆ้ฉใชใใจใๅคใ) ใงๅไฟกใใฆๅบๅใๆๅญใ่ตฐ"
"ๆปใใฆใใใใจใซใชใใ"
#: ../../howto/sockets.rst:228
msgid ""
"One complication to be aware of: if your conversational protocol allows "
"multiple messages to be sent back to back (without some kind of reply), and "
"you pass ``recv`` an arbitrary chunk size, you may end up reading the start "
"of a following message. You'll need to put that aside and hold onto it, "
"until it's needed."
msgstr ""
"ๅฟใซ็ใใฆใใในใ้ขๅใช็นใใฒใจใค: ่คๆฐใกใใปใผใธใๆฌกใ
ใซ (ไฝใใใฎ่ฟไบใๅพ
"
"ใใใซ) ่ฟใฃใฆใใใใจใฎใใไผ่ฉฑใใญใใณใซใชใใใใใฆไปปๆใฎใตใคใบใ "
"``recv`` ใซๆธกใใฆใใใชใใๆฌกใฎใกใใปใผใธใฎๅ้ ญ้จๅใพใง่ชญใใงใใพใใใจใใใ"
"ใใใใใชใใใใฎใจใใฏใๅฟ
่ฆใซใชใใพใง่ใซใใใฆใๅคงๅใซไฟ็ฎกใใฆใใๅฟ
่ฆใ"
"ใใใ"
#: ../../howto/sockets.rst:234
msgid ""
"Prefixing the message with its length (say, as 5 numeric characters) gets "
"more complex, because (believe it or not), you may not get all 5 characters "
"in one ``recv``. In playing around, you'll get away with it; but in high "
"network loads, your code will very quickly break unless you use two ``recv`` "
"loops - the first to determine the length, the second to get the data part "
"of the message. Nasty. This is also when you'll discover that ``send`` does "
"not always manage to get rid of everything in one pass. And despite having "
"read this, you will eventually get bit by it!"
msgstr ""
"ใกใใปใผใธๅ้ ญใซ้ทใใ (ใใจใใฐ 5 ๆกใฎๆฐๅญใง) ไปใใใฎใฏใใใใใใใใใซ่ค"
"้ใซใชใใใจใใใฎใใ(ไฟกใใใใชใใใใใใชใใ) ไธๅใฎ ``recv`` ใง 5 ๆๅญ"
"ใๅ
จ้จๅใๅใใใจใใงใใใจใฏ้ใใชใใใใ ใใ้ใณใงใใฃใฆใใ้ใฏใใพใใ"
"ใฆใใ้ซ่ฒ ่ทใใใใฏใผใฏใฎใใจใงใฏใ``recv`` ใซใผใใใตใใคไฝฟใใชใใณใผใใฏใ"
"ใใฃใจ่จใ้ใซใใกใซใชใฃใฆใใพใ - ไธ็ช็ฎใฏ้ทใใ่ฆๅฎใใ็จใงใไบ็ช็ฎใฏใใผใฟ"
"้จๅใๅใๅใ็จใ ใใใผใใใใใใใใใใใซใใฎใจใใ``send`` ใไธ็บใงๅ
จ้จ"
"ใๅบใๅใใใจใฏ้ใใชใใใจใซๆฐไปใใ ใใใใชใใไปใใใใฃใฆ่ชญใใงใใฆใใ"
"ใใคใ่ชฐใใ็ใ็ฎใ่ฆใใฎใงใใ!"
#: ../../howto/sockets.rst:243
msgid ""
"In the interests of space, building your character, (and preserving my "
"competitive position), these enhancements are left as an exercise for the "
"reader. Lets move on to cleaning up."
msgstr ""
"็ด้ขใฎ้ฝๅใใใณๆ่ฒ็้
ๆ
ฎ (ใจ่่
ใฎๅฐไฝ็ขบไฟ) ใฎใใใใใใใๆน่ฏใฏ็ทด็ฟๅ้ก"
"ใจใใฆๆฎใใฆใใใใใ็ไปใใฆใใพใใใ"
#: ../../howto/sockets.rst:249
msgid "Binary Data"
msgstr "ใใคใใชใใผใฟ"
#: ../../howto/sockets.rst:251
msgid ""
"It is perfectly possible to send binary data over a socket. The major "
"problem is that not all machines use the same formats for binary data. For "
"example, `network byte order <https://en.wikipedia.org/wiki/"
"Endianness#Networking>`_ is big-endian, with the most significant byte "
"first, so a 16 bit integer with the value ``1`` would be the two hex bytes "
"``00 01``. However, most common processors (x86/AMD64, ARM, RISC-V), are "
"little-endian, with the least significant byte first - that same ``1`` would "
"be ``01 00``."
msgstr ""
#: ../../howto/sockets.rst:259
msgid ""
"Socket libraries have calls for converting 16 and 32 bit integers - ``ntohl, "
"htonl, ntohs, htons`` where \"n\" means *network* and \"h\" means *host*, "
"\"s\" means *short* and \"l\" means *long*. Where network order is host "
"order, these do nothing, but where the machine is byte-reversed, these swap "
"the bytes around appropriately."
msgstr ""
#: ../../howto/sockets.rst:265
msgid ""
"In these days of 64-bit machines, the ASCII representation of binary data is "
"frequently smaller than the binary representation. That's because a "
"surprising amount of the time, most integers have the value 0, or maybe 1. "
"The string ``\"0\"`` would be two bytes, while a full 64-bit integer would "
"be 8. Of course, this doesn't fit well with fixed-length messages. "
"Decisions, decisions."
msgstr ""
#: ../../howto/sockets.rst:274
msgid "Disconnecting"
msgstr "ๅๆญ"
#: ../../howto/sockets.rst:276
msgid ""
"Strictly speaking, you're supposed to use ``shutdown`` on a socket before "
"you ``close`` it. The ``shutdown`` is an advisory to the socket at the "
"other end. Depending on the argument you pass it, it can mean \"I'm not "
"going to send anymore, but I'll still listen\", or \"I'm not listening, good "
"riddance!\". Most socket libraries, however, are so used to programmers "
"neglecting to use this piece of etiquette that normally a ``close`` is the "
"same as ``shutdown(); close()``. So in most situations, an explicit "
"``shutdown`` is not needed."
msgstr ""
"ๅณๅฏใซใฏใใฝใฑใใใ ``close`` ใใๅใซใฏ ``shutdown`` ใใใใจใซใชใฃใฆใ"
"ใใ ``shutdown`` ใฏ็ธๆใฝใฑใใใซๅฏพใใๅ ฑๅใงใใใๆธกใๅผๆฐใซใใฃใฆใใใไปฅ"
"ไธใใฃใกใใใฏ้ใใชใใใฉใใพใ ่ใใฆใใใใจใใๆๅณใซใชใฃใใใใใใ่ใ"
"ใชใใใใใใใใ!ใใ ใฃใใใใใใใใใปใจใใฉใฎใฝใฑใใใฉใคใใฉใชใฏใใใฎ"
"ใจใใฑใใใๆ ใใใญใฐใฉใใซๆ
ฃใใฆใใพใฃใฆใ้ๅธธ ``close`` ใ ใใง "
"``shutdown(); close()`` ใจๅใใใจใซใชใใใ ใใๅคงๆตใฏใใใใ ``shutdown`` "
"ใใชใใฆใใใใ"
#: ../../howto/sockets.rst:284
msgid ""
"One way to use ``shutdown`` effectively is in an HTTP-like exchange. The "
"client sends a request and then does a ``shutdown(1)``. This tells the "
"server \"This client is done sending, but can still receive.\" The server "
"can detect \"EOF\" by a receive of 0 bytes. It can assume it has the "
"complete request. The server sends a reply. If the ``send`` completes "
"successfully then, indeed, the client was still receiving."
msgstr ""
"``shutdown`` ใฎๅนๆ็ใชไฝฟใๆนใฎใฒใจใคใฏใHTTP ้ขจใฎใใใจใใ ใใฏใฉใคใขใณใใฏ"
"่ฆๆฑใๅบใใฆใใใซ ``shutdown(1)`` ใใใใใใงใตใผใใซใใใฏใฉใคใขใณใใฏ้ไฟก"
"ๅฎไบใงใใใใพใ ๅไฟกๅฏ่ฝใงใใใจไผใใใใตใผใใฏ 0 ใใคใๅไฟกใง \"EOF\" ใๆค"
"ๅบใใใใจใใงใใใ่ฆๆฑใๆฎใใๅใๅใฃใใใจใซใใฆ่ฏใใฎใ ใๅฏพใใฆใตใผใใฏ"
"่ฟ็ญใ้ใใใใฎ ``send`` ใๆๅใใใชใใใฏใฉใคใขใณใใฏๅฎ้ใซใพใ ๅไฟกใใฆใ"
"ใใใจใซใชใใ"
#: ../../howto/sockets.rst:291
msgid ""
"Python takes the automatic shutdown a step further, and says that when a "
"socket is garbage collected, it will automatically do a ``close`` if it's "
"needed. But relying on this is a very bad habit. If your socket just "
"disappears without doing a ``close``, the socket at the other end may hang "
"indefinitely, thinking you're just being slow. *Please* ``close`` your "
"sockets when you're done."
msgstr ""
"Python ใฏใใฎ่ชๅ shutdown ใใใไธๆญฉ้ฒใใฆใใฝใฑใใใ GC ใใใใจใใซๅฟ
่ฆใช"
"ใ่ชๅใง ``close`` ใใฆใใใใจ่จใฃใฆใใใใใใใใใซ้ ผใใฏใปใใคใใฆใฏใใ"
"ใชใใใใใฝใฑใใใ ``close`` ใใใซๅงฟใๆถใใฐใ็ธๆใฝใฑใใใฏใใกใใ้
ใใ "
"ใใ ใจๆใฃใฆใใณใฐใใฆใใพใใใใใใชใใ *ใ้กใใ ใใ* ็ตใใฃใใใกใใใจ "
"``close`` ใใฆใใใ"
#: ../../howto/sockets.rst:299
msgid "When Sockets Die"
msgstr "ใฝใฑใใใๆญปใฌใจ"
#: ../../howto/sockets.rst:301
msgid ""
"Probably the worst thing about using blocking sockets is what happens when "
"the other side comes down hard (without doing a ``close``). Your socket is "
"likely to hang. TCP is a reliable protocol, and it will wait a long, long "
"time before giving up on a connection. If you're using threads, the entire "
"thread is essentially dead. There's not much you can do about it. As long as "
"you aren't doing something dumb, like holding a lock while doing a blocking "
"read, the thread isn't really consuming much in the way of resources. Do "
"*not* try to kill the thread - part of the reason that threads are more "
"efficient than processes is that they avoid the overhead associated with the "
"automatic recycling of resources. In other words, if you do manage to kill "
"the thread, your whole process is likely to be screwed up."
msgstr ""
"ใใญใใญใณใฐใฝใฑใใใไฝฟใฃใฆใใฆไธ็ชใใใชใฎใฏๅคๅใ็ธๆๅดใๆๅฐๆชใ "
"(``close`` ใใใซ) ใใฆใณใใใจใใซ่ตทใใไบๆใ ใ่ชๅๅดใฎใฝใฑใใใฏ้ซ็ขบ็ใงใ"
"ใณใฐใใใ ใใใTCP ใฏไฟก้ ผๆงใฎ้ซใใใญใใณใซใชใฎใงใใใฃใจใใฃใจๅพ
ใก็ถใใฆใ"
"ใชใใชใ่ฆๆจใฆใชใใฎใ ใในใฌใใใไฝฟใฃใฆใใใฎใงใใใฐใใใฎในใฌใใๅ
จไฝใๆ น"
"ๆฌใใๆญปใใ ็ถๆ
ใซใชใใใใใชใใจใใใๆใฎๆฝใใใใใชใใใพใใใใญใใญใณ"
"ใฐ่ชญใฟๅบใใฎ้ใญใใฏใ็ถใใใจใใฃใ้ฆฌ้นฟใใใใจใใใฆใใชใ้ใใใชใฝใผในใฎ"
"็นใงใฏใใใใฆๆถ่ฒปใซใชใใชใใใ ใใ *ใใฃใใใซ* ใใฎในใฌใใใๆฎบใใใจใใฆ"
"ใฏใใใชใ - ใใญใปในใใในใฌใใใๅน็็ใงใใ็็ฑใฎใฒใจใคใฏใ่ชๅใชใฝใผในๅ"
"ๅใซใพใคใใใชใผใใใใใ้ฟใใใใใจใใ็นใซใใใฎใ ใใคใพใๅฅใฎ่จใๆนใใ"
"ใใจใใฉใใซใใใฆใใฎในใฌใใใๆฎบใใใชใใใใญใปในๅ
จไฝใใใกใใใกใใซใชใฃ"
"ใฆใใพใใ ใใใจใใใใจใ ใ"
#: ../../howto/sockets.rst:315
msgid "Non-blocking Sockets"
msgstr "ใใณใใญใใญใณใฐใฝใฑใใ"
#: ../../howto/sockets.rst:317
msgid ""
"If you've understood the preceding, you already know most of what you need "
"to know about the mechanics of using sockets. You'll still use the same "
"calls, in much the same ways. It's just that, if you do it right, your app "
"will be almost inside-out."
msgstr ""
"ใใใพใง็่งฃใใฆใใใชใใใใใฝใฑใใใฎไป็ตใฟใซใคใใฆๅฟ
่ฆใชใใจใฏใปใจใใฉ"
"็ฅใฃใฆใใใใจใซใชใใใใใใใๅใใณใผใซใใใปใผๅใใใใซไฝฟใฃใฆใใใ ใใ"
"ใใใ ใใ ใใใใใกใใใจใใฃใฆใใใฐใใใฎใขใใชใฏใ ใใใๅฎ็งใงใใใใ"
#: ../../howto/sockets.rst:322
msgid ""
"In Python, you use ``socket.setblocking(False)`` to make it non-blocking. In "
"C, it's more complex, (for one thing, you'll need to choose between the BSD "
"flavor ``O_NONBLOCK`` and the almost indistinguishable POSIX flavor "
"``O_NDELAY``, which is completely different from ``TCP_NODELAY``), but it's "
"the exact same idea. You do this after creating the socket, but before using "
"it. (Actually, if you're nuts, you can switch back and forth.)"
msgstr ""
"Python ใฎๅ ดๅใใใณใใญใใญใณใฐใซใใใซใฏ ``socket.setblocking(False)`` ใไฝฟ"
"ใใ C ใชใใใฃใจ่ค้ใ (ไธไพใๆใใใจใBSD ๆนๅผใฎ ``O_NONBLOCK`` ใใใณใปใผ"
"้ใใฎใชใ POSIX ๆนๅผ ``O_NDELAY`` ใฎใฉใกใใ้ธใถใๆฑบใใชใใฆใฏใชใใชใใฆใๅพ"
"่
ใฏ ``TCP_NODELAY`` ใจใฏๅ
จ็ถๅฅ็ฉใ ใฃใใใใ) ใใ่ใๆนใฏใพใฃใใไธ็ทใ ใใ"
"ใใฏใใฝใฑใใใไฝๆใใๅพใไฝฟ็จใใๅใซ่กใใ(ๅฎ้ใๅธธ่ญ็ ดใใชใใๅใๆฟใใ"
"ใใจใใงใใพใใ)"
#: ../../howto/sockets.rst:329
msgid ""
"The major mechanical difference is that ``send``, ``recv``, ``connect`` and "
"``accept`` can return without having done anything. You have (of course) a "
"number of choices. You can check return code and error codes and generally "
"drive yourself crazy. If you don't believe me, try it sometime. Your app "
"will grow large, buggy and suck CPU. So let's skip the brain-dead solutions "
"and do it right."
msgstr ""
"ๆง้ ไธใฎๅคงใใช้ใใฏใ ``send``, ``recv``, ``connect``, ``accept`` ใไฝใใใช"
"ใใงๆปใฃใฆใใใใใใใชใใจใใ็นใงใใใ้ธๆ่ขใฏ (ๅฝ็ถใชใใ) ใใใคใใ"
"ใใ่ฟใๅคใจใจใฉใผใณใผใใใใงใใฏใใใจใใๆนๆณใใใใใใ็บ็ใใใใจ่ซใ"
"ๅใใ ใไฟกใใชใใชใใใใคใใใฃใฆใฟใใจใใใใขใใชใฏ่ฅๅคงๅใใใใฐใๅขใใ"
"CPU ใๅฐใๅฐฝใใใ ใใใใ ใใใใใชๆใใช่งฃๆณใฏ้ฃใฐใใฆใๆญฃ่งฃใซ้ฒใใใ"
#: ../../howto/sockets.rst:336
msgid "Use ``select``."
msgstr "``select`` ใไฝฟใใ"
#: ../../howto/sockets.rst:338
msgid ""
"In C, coding ``select`` is fairly complex. In Python, it's a piece of cake, "
"but it's close enough to the C version that if you understand ``select`` in "
"Python, you'll have little trouble with it in C::"
msgstr ""
"C ใซใใใฆ ``select`` ใงใณใผใใๆธใใฎใฏใใชใ้ขๅใ ใใPython ใชใ้ ไฝใใช"
"ใใใใใ Python ใง ``select`` ใ็่งฃใใฆใใใฐ C ใงใใปใจใใฉๅ้กใชใๆธใ"
"ใใใจใใ็จๅบฆใซใฏไผผใฆใใ::"
#: ../../howto/sockets.rst:342
msgid ""
"ready_to_read, ready_to_write, in_error = \\\n"
" select.select(\n"
" potential_readers,\n"
" potential_writers,\n"
" potential_errs,\n"
" timeout)"
msgstr ""
#: ../../howto/sockets.rst:349
msgid ""
"You pass ``select`` three lists: the first contains all sockets that you "
"might want to try reading; the second all the sockets you might want to try "
"writing to, and the last (normally left empty) those that you want to check "
"for errors. You should note that a socket can go into more than one list. "
"The ``select`` call is blocking, but you can give it a timeout. This is "
"generally a sensible thing to do - give it a nice long timeout (say a "
"minute) unless you have good reason to do otherwise."
msgstr ""
"``select`` ใซไธใคใฎใชในใใๆธกใใฆใใใใไธ็ช็ฎใซใฏใใจใง่ชญใฟใใใชใใใใใ"
"ใชใใฝใฑใใใในใฆใไบ็ช็ฎใซใฏๆธใ่พผใฟใใใชใใใใใใชใใฝใฑใใใในใฆใๆ"
"ๅพใซ (้ๅธธใฏ็ฉบใฎใพใพใ ใ) ใจใฉใผใใใงใใฏใใใใฝใฑใใใๅ
ฅใฃใฆใใใใฒใจใค"
"ใฎใฝใฑใใใ่คๆฐใซใพใใใฃใฆใชในใใใใฆใๆงใใชใใใจใๆถใใฆใใใจ่ฏใใใช"
"ใใ ``select`` ใณใผใซใฏใใญใใฏใใใใๆ้ๅถ้ใไธใใใใจใใงใใใใใ"
"ใฏใใใฃใฆใใใฆๆใฏใชใ - ็นใซ็็ฑใใชใใใฐใใใชใ้ทใ (ใใจใใฐ 1 ๅใจใ"
"ใฎ) ๆ้ๅถ้ใไปใใฆใใใใจใ ใ"
#: ../../howto/sockets.rst:357
msgid ""
"In return, you will get three lists. They contain the sockets that are "
"actually readable, writable and in error. Each of these lists is a subset "
"(possibly empty) of the corresponding list you passed in."
msgstr ""
"ๆปใๅคใจใใฆใไธใคใฎใชในใใๆใซๅ
ฅใใใใใใใซใฏใๅฎ้ใซ่ชญใใใฝใฑใใใๆธ"
"ใใใฝใฑใใใใจใฉใผไธญใฎใฝใฑใใใๅ
ฅใฃใฆใใฆใๆธกใใใชในใใฎ้จๅ้ๅ (็ฉบ้ๅ"
"ใใใใใชใ) ใซใชใฃใฆใใใ"
#: ../../howto/sockets.rst:361
msgid ""
"If a socket is in the output readable list, you can be as-close-to-certain-"
"as-we-ever-get-in-this-business that a ``recv`` on that socket will return "
"*something*. Same idea for the writable list. You'll be able to send "
"*something*. Maybe not all you want to, but *something* is better than "
"nothing. (Actually, any reasonably healthy socket will return as writable - "
"it just means outbound network buffer space is available.)"
msgstr ""
"ๅบๅใฎใใกใreadable ใชในใใซใใใฝใฑใใใซใคใใฆใฏใ ``recv`` ใใจใใใใ *"
"ไฝใ* ใ่ฟใใงใใใใใจใใใใจใฏๅฒไธๆ้ซๅบฆใซ็ขบไฟกใงใใใ writable ใชในใใ"
"่ใๆนใฏๅใใงใ *ไฝใ* ใฏ้ใใใ้ใใใใใฎๅ
จไฝใฏ็ก็ใใใใใชใใใ *ไฝ"
"ใ* ใชใใใใฏใใทใ ใใใ (ๅฎใฎใจใใใใตใคใใซๅฅๅบทใชใฝใฑใใใชใ writable "
"ใง่ฟใฃใฆใใใใจใใงใใ - ใใใฏๅคๅใใใใใฏใผใฏใใใใกใซ็ฉบใใใใใจใใ"
"ใ ใใฎๆๅณใใใชใใฎใ ใใ)"
#: ../../howto/sockets.rst:368
msgid ""
"If you have a \"server\" socket, put it in the potential_readers list. If it "
"comes out in the readable list, your ``accept`` will (almost certainly) "
"work. If you have created a new socket to ``connect`` to someone else, put "
"it in the potential_writers list. If it shows up in the writable list, you "
"have a decent chance that it has connected."
msgstr ""
"ใใตใผใใใฝใฑใใใฏ potential_readers ใชในใใซๅ
ฅใใฆใใใใใใใ readable "
"ใชในใใซๅ
ฅใฃใฆๅบใฆใใใใ ``accept`` ใฏ (ใปใผ) ็ขบๅฎใซๆๅใใใฏใใ ใใฉใใ"
"ใธ ``connect`` ใใใใใซไฝใฃใๆฐใใใฝใฑใใใฏ potential_writers ใชในใใซๅ
ฅ"
"ใใใใใใ writable ใชในใใซ็พใใใใๆฅ็ถใๆๅใใฆใใๅฏ่ฝๆงใฏ้ซใใจ่จใ"
"ใใ"
#: ../../howto/sockets.rst:374
msgid ""
"Actually, ``select`` can be handy even with blocking sockets. It's one way "
"of determining whether you will block - the socket returns as readable when "
"there's something in the buffers. However, this still doesn't help with the "
"problem of determining whether the other end is done, or just busy with "
"something else."
msgstr ""
"ใใคใฏ ``select`` ใฏใใญใใญใณใฐใฝใฑใใใซใไพฟๅฉใซไฝฟใใใใใใฏใใญใใฏใใ"
"ใใฉใใใ่ฆๆฅตใใๆนๆณใฎใฒใจใคใงใใ - ใใใใกใซไฝใใใใใฐ readable ใจใใฆ"
"่ฟใฃใฆใใใฎใ ใใใใใใใใ็ธๆใฎ็จไบใใใๆธใใงใใใฎใใใใใจใๅใซไป"
"ใฎใใจใงๅฟใใใ ใใชใฎใใ่ฆๆฅตใใๅฝนใซใฏ็ซใใชใใ"
#: ../../howto/sockets.rst:379
msgid ""
"**Portability alert**: On Unix, ``select`` works both with the sockets and "
"files. Don't try this on Windows. On Windows, ``select`` works with sockets "
"only. Also note that in C, many of the more advanced socket options are done "
"differently on Windows. In fact, on Windows I usually use threads (which "
"work very, very well) with my sockets."
msgstr ""
"**้ไบๆ่ญฆๅ ฑ**: Unix ใงใฏใฝใฑใใใซใใใกใคใซใซใ ``select`` ใไฝฟใใใใใ"
"ใ Windows ใงใใใใจใใฆใฏใใใชใใWindows ใง ``select`` ใฏใฝใฑใใใซใใไฝฟ"
"ใใชใใใพใ C ใฎๅ ดๅใ้ซๅบฆใชใฝใฑใใใชใใทใงใณใฎๅคใใฏใใใๆนใ Windows ใง"
"ใฏ้ใฃใฆใใใๅฎ้ใWindows ใชใ่่
ใฏ้ๅธธใใฝใฑใใใซในใฌใใใไฝฟใฃใฆใใ "
"(ใใใฏๅฎใซใๅฎใซใใพใใใ)ใ"