realpython / realpython/materials
multiconn-client.py sometimes concatenates messages
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Jupyter Notebook
- Sterne
- 5.2k
- Forks
- 5.3k
- Ø Merge
- 4 T. 10 Std.
- Gemergte PRs (30 T.)
- 10
Beschreibung
@dbader, thanks very much for your example code.
Description of the bug
Running the multi-connection example from the python-sockets-tutorial, ie,
- materials/python-sockets-tutorial/multiconn-client.py
sometimes, but not always, concatenates the two messages.
To Reproduce
Start the server and view the output from when the client is run (see below)
python -u multiconn-server.py 127.0.0.1 65432
listening on ('127.0.0.1', 65432)
accepted connection from ('127.0.0.1', 50484)
echoing b'Message 1 from client.' to ('127.0.0.1', 50484)
echoing b'Message 2 from client.' to ('127.0.0.1', 50484)
closing connection to ('127.0.0.1', 50484)
accepted connection from ('127.0.0.1', 50486)
echoing b'Message 1 from client.Message 2 from client.' to ('127.0.0.1', 50486)
closing connection to ('127.0.0.1', 50486)
Run the client twice with 1 connection (see below). The first run gives expected results, the second run concatenates the two messages (as can be seen below). The concatenation is also evident in the output from multiconn-server.py above.
python -u multiconn-client.py 127.0.0.1 65432 1
starting connection 1 to ('127.0.0.1', 65432)
sending b'Message 1 from client.' to connection 1
sending b'Message 2 from client.' to connection 1
received b'Message 1 from client.' from connection 1
received b'Message 2 from client.' from connection 1
closing connection 1
python -u multiconn-client.py 127.0.0.1 65432 1
starting connection 1 to ('127.0.0.1', 65432)
sending b'Message 1 from client.' to connection 1
sending b'Message 2 from client.' to connection 1
received b'Message 1 from client.Message 2 from client.' from connection 1
closing connection 1
Expected behavior
The output form the second run of the multiconn-client.py should be identical to the output from the first run.
Desktop (please complete the following information):
- OS: CentOS 7
- Browser: Firefox
- Version 91.2.0esr (64-bit)
Additional context
Python 3.8.0
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne mit materials/python-sockets-tutorial/multiconn-client.py und multiconn-server.py und reproduziere anschließend das Problem mithilfe der beiden gezeigten Befehle, während der Server auf 127.0.0.1:65432 läuft. Verfolge, wie der Client die beiden Nachrichten sendet und empfängt und wie der Server sie protokolliert; fertig ist es, wenn der zweite Durchlauf jede Nachricht separat meldet und dem ersten Durchlauf entspricht.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- python
- Bereich
- networking
- Issue-Typ
- Bug
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Klar beschrieben
- Anfängerfreundlichkeit
- 45/100