0

I am taking a class in Coursera with Michigan University on Python and the professor showed three lines of code that establish a connection. The first imports the library, the second opens a socket and the third establishes a connection. However, I got an error message after the second line:

        import socket

        mysock = socket.socket(socket.AF_INET, socket.sock_STREAM)

        mysock.connect(( 'www.py4inf.com', 80))

Error message:

        Traceback (most recent call last):

        File "<ipython-input-12-2ff379ebad44>", line 1, in <module>
        mysock = socket.socket(socket.AF_INET, socket.sock_STREAM)

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

I researched the web on that error and the advice that is give is to remove from working directory file named socket.py. However, in my case the working directory is empty. Thank you for your comments.

0

1 Answer 1

3

Give socket.SOCK_STREAM a try (note the case change).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.