title: list/array of (multi-threaded) sockets in python
body: <p>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:</p>
  
  <pre><code>myCSocks = ['CSock1', 'CSock2', 'CSock3', 'CSock4', 'CSock5']
  </code></pre>
  
  <p>And I am trying to use my array elements as follows:</p>
  
  <pre><code>myCSocks[i], addr = serverSocket.accept()
  message = myCSocks[i].recv(1024)
  </code></pre>
  
  <p>I am getting the following error:</p>
  
  <pre><code>Traceback (most recent call last):
    File "./htmlserv_multi.py", line 22, in &lt;module&gt;
      message = myCSocks[i].recv(1024)
  AttributeError: 'str' object has no attribute 'recv'
  </code></pre>
  
  <p>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. </p>
  
  <p>PS: My final objective is to create a very simple multithreaded TCP web server (using python)</p>
  
  <p>CODE:</p>
  
  <pre><code>#! /usr/bin/env python
  from socket import *
  
  #does this work?
  myCSocks = []
  
  serverSocket = socket(AF_INET, SOCK_STREAM)
  serverSocket.bind(('192.168.1.4',12000))
  serverSocket.listen(5)
  while True:
    for i in range(0, len(myCSocks)+1):
      myCSocks[i], addr = serverSocket.accept()
    try:
      for i in range(0, len(myCSocks)):
        message = myCSocks[i].recv(1024)
        filename = message.split()[1]
        f = open(filename[1:])
        outputdata = f.read()
        myCSocks[i].send('HTTP/1.1 200 OK\r\n\r\n')
        for p in range(0, len(outputdata)):
          myCSocks[i].send(outputdata[p])
        myCSocks[i].close()
    except IOError:
      connectionSocket.send('HTTP/1.1 404 Bad Request\r\n\r\n')
      connectionSocket.send('&lt;HTML&gt;&lt;p&gt;ERROR 404: BAD REQUEST!&lt;/p&gt;&lt;/HTML&gt;')
      serverSocket.close()
      exit()
  </code></pre>