array/list of sockets

theelder777 at gmail.com theelder777 at gmail.com
Sat Oct 26 17:41:15 EDT 2013


Hello all, I am kind of new to python. I am currently trying to make and use a list/array of sockets in a program. So I have declared an array as follows:
myCSocks = ['CSock1', 'CSock2', 'CSock3', 'CSock4', 'CSock5']

and I am trying to use my array elements as follows:
myCSocks[i], addr = serverSocket.accept()
 and 
message = myCSocks[i].recv(1024)

I am getting the following error:
Traceback (most recent call last):
  File "./htmlserv_multi.py", line 22, in <module>
    message = myCSocks[i].recv(1024)
AttributeError: 'str' object has no attribute 'recv'


This kind of makes sense to me, it is saying that my array elements are of type String and are not sockets. So I understand what my problem is but I do not know how to remedy it. I have googled "list of sockets python" but did not find anything. Any help will be greatly appreciated. Thank you. 




More information about the Python-list mailing list