i have this small script which after some router configurations works.
############### ############### ############### #############
#! /usr/bin/python
import socket
HOST = ''
PORT = 1515
s = socket.socket(s ocket.AF_INET, socket.SOCK_STR EAM)
s.bind((HOST, PORT))
s.listen(1)
conn, addr = s.accept()
conn.send('HTTP/1.1 200 OK\r\n')
conn.send('Cont ent-Type: text/html\r\n')
conn.send('Serv er: test/1.0\r\n\r\n')
conn.send('<htm l><body>test</body></html>')
s.close()
############### ############### ############### #############
as you see it listens to 1515 until a connection is established and
then it accepts it...
the problem is that when it accepts the connection it sends those
strings and exits, but then it exits the program. i want it to listen
to 1515 then accept a connection, send.. and then listen to the port
again and again until new connections are found.
i've been struggling with try..except,whi le and all kinds of loops but
always new erros pop up, or it overflows.
############### ############### ############### #############
#! /usr/bin/python
import socket
HOST = ''
PORT = 1515
s = socket.socket(s ocket.AF_INET, socket.SOCK_STR EAM)
s.bind((HOST, PORT))
s.listen(1)
conn, addr = s.accept()
conn.send('HTTP/1.1 200 OK\r\n')
conn.send('Cont ent-Type: text/html\r\n')
conn.send('Serv er: test/1.0\r\n\r\n')
conn.send('<htm l><body>test</body></html>')
s.close()
############### ############### ############### #############
as you see it listens to 1515 until a connection is established and
then it accepts it...
the problem is that when it accepts the connection it sends those
strings and exits, but then it exits the program. i want it to listen
to 1515 then accept a connection, send.. and then listen to the port
again and again until new connections are found.
i've been struggling with try..except,whi le and all kinds of loops but
always new erros pop up, or it overflows.
Comment