This is a code cleanup to help me better understand the network.py code.
Add typehints where the IDE cannot guees the type, use.
Use an Enum for interface modes for better type-safety and more helpful IDE assistance, r.
Remove an unused TCPConnection.protocol attributete.
Use the more modern NamedTuple class definition.