Pseduo-TCP implementation in Python