Need help with a script 12-11-2012, 05:59 PM
#1
Hello!
I have been sitting on a script for a multi-thread server for a while.
I have no idea how to change the bold bit of code, co it will work.
The script is taken from a tutorial, bu the tutorial was not completely working.
The highlighted part is the one that does not work. Server starts up normally, but when I try connecting, it does not work![Sad Sad](https://sinister.ly/images/smilies/set/sad.png)
Any ideas what I should do?
I know that the client_thread is not defined anywhere, but I have no idea what to put instead. I am on Python 3.2
Any help would be appreciated. Thank you
I have been sitting on a script for a multi-thread server for a while.
I have no idea how to change the bold bit of code, co it will work.
The script is taken from a tutorial, bu the tutorial was not completely working.
The highlighted part is the one that does not work. Server starts up normally, but when I try connecting, it does not work
![Sad Sad](https://sinister.ly/images/smilies/set/sad.png)
Any ideas what I should do?
I know that the client_thread is not defined anywhere, but I have no idea what to put instead. I am on Python 3.2
Code:
import socket
import threading
import _thread
print('Starting server...')
print('Setting up details...')
HOST = 'localhost'
PORT = 8050
BUFSIZ = 1024
ADDR = (HOST, PORT)
print('Setting up listener...')
serversock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
serversock.bind(ADDR)
serversock.listen(2)
while 1:
print('Done! Waiting for connections...')
clientsocket = serversock.accept()
print('Connected from', clientsocket)
[u][b] ct = client_thread(clientsocket)[/b][/u]
ct.run()
print('Closing Thread')
serversock.close()
Any help would be appreciated. Thank you