[Tutor] Socket not connecting

Jacob Bender benderjacob44 at gmail.com
Wed Oct 19 01:26:19 CEST 2011


Dear Tutors,

     I'm the same person who asked about intruders getting into my computer
via socket. I tried copying a socket program from online, that worked on my
computer, and executed perfectly. However, I did not open a port for python,
but I do have an exception in my firewall. Anyhow, I called the same friend
and had him run a client program when I was running the host program. The
host program did absolutely nothing and my IP was programmed into the client
as the "Host IP". I took all necessary steps and even turned off my
antivirus, which didn't help at all. I also told my friend and now he has an
exception on his antivirus, but still nothing is working. I've been using
port 80 the whole time. Is there anything I did wrong, or a step I've
missed? Here is the source code for both the server and the client I was
talking about:

*Client:*
*
*
# Echo client program
import socket

HOST = '# my IP was once here'    # The remote host
PORT = 80           # The same port as used by the server
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((HOST, PORT))
s.send('Hello, world')
data = s.recv(1024)
s.close()
print 'Received', repr(data)

*
*
*Server:*
*
*
# Echo server program
import socket

HOST = ''                 # Symbolic name meaning all available interfaces
PORT = 80              # Arbitrary non-privileged port
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind((HOST, PORT))
s.listen(1)
conn, addr = s.accept()
print 'Connected by', addr
while 1:
    data = conn.recv(1024)
    if not data: break
    conn.send(data)
conn.close()

Thanks!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20111018/3e0fa35a/attachment.html>


More information about the Tutor mailing list