summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2011-10-06 18:27:20 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2011-10-06 18:27:20 (GMT)
commitb09460f03879e0c41a72b7dd79dd16431f0bb3e6 (patch)
tree6bd60ba9d4ccc4a69eba6511208a6b24c2f7806a /Doc
parent47413c117145c3da7cdb0ded5c05d0d540a26a4a (diff)
downloadcpython-b09460f03879e0c41a72b7dd79dd16431f0bb3e6.zip
cpython-b09460f03879e0c41a72b7dd79dd16431f0bb3e6.tar.gz
cpython-b09460f03879e0c41a72b7dd79dd16431f0bb3e6.tar.bz2
Issue #10141: Don't use hardcoded frame size in example, use struct.calcsize()
Diffstat (limited to 'Doc')
-rw-r--r--Doc/library/socket.rst3
1 files changed, 2 insertions, 1 deletions
diff --git a/Doc/library/socket.rst b/Doc/library/socket.rst
index 030a421..f9e0780 100644
--- a/Doc/library/socket.rst
+++ b/Doc/library/socket.rst
@@ -1270,6 +1270,7 @@ network. This example might require special priviledge::
# CAN frame packing/unpacking (see `struct can_frame` in <linux/can.h>)
can_frame_fmt = "=IB3x8s"
+ can_frame_size = struct.calcsize(can_frame_fmt)
def build_can_frame(can_id, data):
can_dlc = len(data)
@@ -1286,7 +1287,7 @@ network. This example might require special priviledge::
s.bind(('vcan0',))
while True:
- cf, addr = s.recvfrom(16)
+ cf, addr = s.recvfrom(can_frame_size)
print('Received: can_id=%x, can_dlc=%x, data=%s' % dissect_can_frame(cf))