When you do from socket import *
python is loading a socket
module to the current namespace. Thus you can use module's members as if they are defined within your current python module.
When you do import socket
, a module is loaded in a separate namespace. When you are accessing its members, you should prefix them with a module name. For example, if you want to refer to a socket
class, you will need to write client_socket = socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
.
As for the problem with timeout - all you need to do is to change except socket.Timeouterror:
to except timeout:
, since timeout
class is defined inside socket
module and you have imported all its members to your namespace.