added try-except when sending and recving from sockets.
also, added a check before removing sockets from variuos lists (if s in outputs: outputs.remove(s))