Skip to content

Commit

Permalink
Update datagram receive example to use fstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
pvcraven committed Dec 3, 2021
1 parent 45e798e commit 13f6208
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions datagram_receive_blocking.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,8 @@

while True:
# Receive our data
data, source_address = s.recvfrom(buffer_size)
print("From {}:{}: {}".format(source_address[0], source_address[1], data))
data, source = s.recvfrom(buffer_size)
# "source" is a list of two items, the IP and the port.
# Unpack the source into separate values.
source_address, source_port = source
print(f"From {source_address}:{source_port}: {data}")

0 comments on commit 13f6208

Please sign in to comment.