Hey guys, I'm trying to get a socket to work, but this code doesn't seem to fire.

#!/usr/bin/python
import sys
import os
import socket

serverHost = 'localhost'            # servername is localhost
serverPort = 2000                   # use arbitrary port > 1024

mySocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)    # create a TCP socket

The error is

File ".//socketTest.py", line 4, in <module>
import socket
File "/usr/lib/python2.5/socket.py", line 9, in <module>

AttributeError: 'module' object has no attribute 'AF_INET'

Any one shed any light to it?

Wow, that's weird.

>>> import socket
>>> socket.AF_INET
2
>>>

Can you reproduce my results?

Jeff

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.