I tried the socket module in Python, but whenever I try to run this code:
import socket import sys host = '192.168.1.1' port = 23 try: s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) except: print "socket() failed" sys.exit(1)
Then he dies. Here is the error without exception and try:
Traceback (most recent call last): File "C:\Documents and Settings\a\Desktop\socket.py", line 1, in <module> import socket File "C:\Documents and Settings\a\Desktop\socket.py", line 6, in <module> s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) AttributeError: 'module' object has no attribute 'AF_INET'
I just started Python (Today) and I need help.
I saved it as socket.py, but also sock.py ...
source share