Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
6e13f130
Kaydet (Commit)
6e13f130
authored
Şub 09, 2012
tarafından
Senthil Kumaran
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fix Issue #6005: Examples in the socket library documentation use sendall,
where relevant, instead send method.
üst
b2c9e9ad
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
11 deletions
+17
-11
sockets.rst
Doc/howto/sockets.rst
+2
-0
socket.rst
Doc/library/socket.rst
+7
-6
socketserver.rst
Doc/library/socketserver.rst
+5
-5
NEWS
Misc/NEWS
+3
-0
No files found.
Doc/howto/sockets.rst
Dosyayı görüntüle @
6e13f130
.. _socket-howto:
****************************
****************************
Socket Programming HOWTO
Socket Programming HOWTO
****************************
****************************
...
...
Doc/library/socket.rst
Dosyayı görüntüle @
6e13f130
...
@@ -731,7 +731,8 @@ correspond to Unix system calls applicable to sockets.
...
@@ -731,7 +731,8 @@ correspond to Unix system calls applicable to sockets.
optional *flags* argument has the same meaning as for :meth:`recv` above.
optional *flags* argument has the same meaning as for :meth:`recv` above.
Returns the number of bytes sent. Applications are responsible for checking that
Returns the number of bytes sent. Applications are responsible for checking that
all data has been sent; if only some of the data was transmitted, the
all data has been sent; if only some of the data was transmitted, the
application needs to attempt delivery of the remaining data.
application needs to attempt delivery of the remaining data. For further
information on this topic, consult the :ref:`socket-howto`.
.. method:: socket.sendall(bytes[, flags])
.. method:: socket.sendall(bytes[, flags])
...
@@ -886,8 +887,8 @@ using it. Note that a server must perform the sequence :func:`socket`,
...
@@ -886,8 +887,8 @@ using it. Note that a server must perform the sequence :func:`socket`,
:meth:`~socket.bind`, :meth:`~socket.listen`, :meth:`~socket.accept` (possibly
:meth:`~socket.bind`, :meth:`~socket.listen`, :meth:`~socket.accept` (possibly
repeating the :meth:`~socket.accept` to service more than one client), while a
repeating the :meth:`~socket.accept` to service more than one client), while a
client only needs the sequence :func:`socket`, :meth:`~socket.connect`. Also
client only needs the sequence :func:`socket`, :meth:`~socket.connect`. Also
note that the server does not :meth:`~socket.send
`/:meth:`~socket.recv` on the
note that the server does not :meth:`~socket.send
all`/:meth:`~socket.recv` on
socket it is listening on but on the new socket returned by
the
socket it is listening on but on the new socket returned by
:meth:`~socket.accept`.
:meth:`~socket.accept`.
The first two examples support IPv4 only. ::
The first two examples support IPv4 only. ::
...
@@ -905,7 +906,7 @@ The first two examples support IPv4 only. ::
...
@@ -905,7 +906,7 @@ The first two examples support IPv4 only. ::
while True:
while True:
data = conn.recv(1024)
data = conn.recv(1024)
if not data: break
if not data: break
conn.send(data)
conn.send
all
(data)
conn.close()
conn.close()
::
::
...
@@ -917,7 +918,7 @@ The first two examples support IPv4 only. ::
...
@@ -917,7 +918,7 @@ The first two examples support IPv4 only. ::
PORT = 50007 # The same port as used by the server
PORT = 50007 # The same port as used by the server
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((HOST, PORT))
s.connect((HOST, PORT))
s.send(b'Hello, world')
s.send
all
(b'Hello, world')
data = s.recv(1024)
data = s.recv(1024)
s.close()
s.close()
print('Received', repr(data))
print('Received', repr(data))
...
@@ -989,7 +990,7 @@ sends traffic to the first one connected successfully. ::
...
@@ -989,7 +990,7 @@ sends traffic to the first one connected successfully. ::
if s is None:
if s is None:
print('could not open socket')
print('could not open socket')
sys.exit(1)
sys.exit(1)
s.send(b'Hello, world')
s.send
all
(b'Hello, world')
data = s.recv(1024)
data = s.recv(1024)
s.close()
s.close()
print('Received', repr(data))
print('Received', repr(data))
...
...
Doc/library/socketserver.rst
Dosyayı görüntüle @
6e13f130
...
@@ -353,7 +353,7 @@ This is the server side::
...
@@ -353,7 +353,7 @@ This is the server side::
print("{} wrote:".format(self.client_address[0]))
print("{} wrote:".format(self.client_address[0]))
print(self.data)
print(self.data)
# just send back the same data, but upper-cased
# just send back the same data, but upper-cased
self.request.send(self.data.upper())
self.request.send
all
(self.data.upper())
if __name__ == "__main__":
if __name__ == "__main__":
HOST, PORT = "localhost", 9999
HOST, PORT = "localhost", 9999
...
@@ -383,7 +383,7 @@ objects that simplify communication by providing the standard file interface)::
...
@@ -383,7 +383,7 @@ objects that simplify communication by providing the standard file interface)::
The difference is that the ``readline()`` call in the second handler will call
The difference is that the ``readline()`` call in the second handler will call
``recv()`` multiple times until it encounters a newline character, while the
``recv()`` multiple times until it encounters a newline character, while the
single ``recv()`` call in the first handler will just return what has been sent
single ``recv()`` call in the first handler will just return what has been sent
from the client in one ``send()`` call.
from the client in one ``send
all
()`` call.
This is the client side::
This is the client side::
...
@@ -400,7 +400,7 @@ This is the client side::
...
@@ -400,7 +400,7 @@ This is the client side::
try:
try:
# Connect to server and send data
# Connect to server and send data
sock.connect((HOST, PORT))
sock.connect((HOST, PORT))
sock.send(bytes(data + "\n", "utf-8"))
sock.send
all
(bytes(data + "\n", "utf-8"))
# Receive data from the server and shut down
# Receive data from the server and shut down
received = str(sock.recv(1024), "utf-8")
received = str(sock.recv(1024), "utf-8")
...
@@ -498,7 +498,7 @@ An example for the :class:`ThreadingMixIn` class::
...
@@ -498,7 +498,7 @@ An example for the :class:`ThreadingMixIn` class::
data = str(self.request.recv(1024), 'ascii')
data = str(self.request.recv(1024), 'ascii')
cur_thread = threading.current_thread()
cur_thread = threading.current_thread()
response = bytes("{}: {}".format(cur_thread.name, data), 'ascii')
response = bytes("{}: {}".format(cur_thread.name, data), 'ascii')
self.request.send(response)
self.request.send
all
(response)
class ThreadedTCPServer(socketserver.ThreadingMixIn, socketserver.TCPServer):
class ThreadedTCPServer(socketserver.ThreadingMixIn, socketserver.TCPServer):
pass
pass
...
@@ -507,7 +507,7 @@ An example for the :class:`ThreadingMixIn` class::
...
@@ -507,7 +507,7 @@ An example for the :class:`ThreadingMixIn` class::
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect((ip, port))
sock.connect((ip, port))
try:
try:
sock.send(bytes(message, 'ascii'))
sock.send
all
(bytes(message, 'ascii'))
response = str(sock.recv(1024), 'ascii')
response = str(sock.recv(1024), 'ascii')
print("Received: {}".format(response))
print("Received: {}".format(response))
finally:
finally:
...
...
Misc/NEWS
Dosyayı görüntüle @
6e13f130
...
@@ -113,6 +113,9 @@ Core and Builtins
...
@@ -113,6 +113,9 @@ Core and Builtins
Library
Library
-------
-------
- Issue #6005: Examples in the socket library documentation use sendall, where
relevant, instead send method.
- Issue #10811: Fix recursive usage of cursors. Instead of crashing,
- Issue #10811: Fix recursive usage of cursors. Instead of crashing,
raise a ProgrammingError now.
raise a ProgrammingError now.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment