954,546 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Socket problem

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
import socket
File "/usr/lib/python2.5/socket.py", line 9, in

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

Any one shed any light to it?

Acidburn
Posting Pro
512 posts since Dec 2004
Reputation Points: 12
Solved Threads: 5
 

Wow, that's weird.

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


Can you reproduce my results?

Jeff

jrcagle
Practically a Master Poster
608 posts since Jul 2006
Reputation Points: 92
Solved Threads: 156
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You