Where is fd defined? To have it stay the same for multiple events and not be redefined it should be set outside of the input_changed() function (activate(), the global scope, etc...). Also, if you are making a tcp connection to send the player state, it might just be better to set up and tear down t...