tcp

castironpi at gmail.com castironpi at gmail.com
Sun Mar 2 14:21:26 EST 2008


On Mar 2, 11:38 am, Steve Holden <st... at holdenweb.com> wrote:
> Nobody thinks you are a fool for wanting help with your problems, it's
> simply that you have to provide enough information about what' wring for
> us to get a handle on the issues.

This worked:

import socket
from time import time

for i in range( 20 ):
    HOST = ''
    PORT = 80 #<----
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.bind((HOST, PORT))
    print( 'listen' )
    s.listen(1)
    conn, addr = s.accept()
    print( 'connected', addr )
    print( conn.recv( 4096 ) ) #<----
    conn.send( bytes('<html><body>test %f</body></
html>'%time(),'ascii') )
    conn.close() #<----
    s.close()

... and connect with a browser:  http://localhost/ if it's internet
exploder.



More information about the Python-list mailing list