Implementing socket.putback