Skip to content

Commit

Permalink
Replace "IN" module import with inlined constants
Browse files Browse the repository at this point in the history
  • Loading branch information
brandon-rhodes committed Aug 14, 2017
1 parent c13583b commit 9530289
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions py3/chapter02/big_sender.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,17 @@
# Send a big UDP datagram to learn the MTU of the network path.

import argparse, socket, sys
try:
import IN
except ImportError:
IN = None

if not hasattr(IN, 'IP_MTU'):
print('Unsupported: Cannot perform MTU discovery on this combination of\n'
' operating system and Python version', file=sys.stderr)
# Inlined constants, because Python 3.6 has dropped the IN module.

class IN:
IP_MTU = 14
IP_MTU_DISCOVER = 10
IP_PMTUDISC_DO = 2

if sys.platform != 'linux':
print('Unsupported: Can only perform MTU discovery on Linux',
file=sys.stderr)
sys.exit(1)

def send_big_datagram(host, port):
Expand Down

0 comments on commit 9530289

Please sign in to comment.