Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #57671

Re: array/list of sockets

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!ecngs!feeder2.ecngs.de!newsfeeder.ewetel.de!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'python.': 0.02; 'from:addr:yahoo.co.uk': 0.04; 'attribute': 0.07; 'error:': 0.07; 'string': 0.09; '22,': 0.09; 'lawrence': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'tismer': 0.09; 'python': 0.11; '"list': 0.16; 'addr': 0.16; 'declared': 0.16; 'googled': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'sockets': 0.16; 'subject:array': 0.16; 'elements': 0.16; 'language': 0.16; 'wrote:': 0.18; 'all,': 0.19; 'trying': 0.19; 'programming': 0.22; 'saying': 0.22; 'header:User-Agent:1': 0.23; 'second': 0.26; 'subject:/': 0.26; 'skip:" 20': 0.27; 'header:X -Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'appreciated.': 0.29; 'array': 0.29; 'subject:list': 0.30; 'getting': 0.31; 'python"': 0.31; 'file': 0.32; 'url:python': 0.33; '(most': 0.33; 'sense': 0.34; 'problem': 0.35; 'but': 0.35; 'url:org': 0.36; 'list': 0.37; 'christian': 0.38; 'thank': 0.38; 'follows:': 0.38; 'url:library': 0.38; 'to:addr:python-list': 0.38; 'recent': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'how': 0.40; 'new': 0.61; 'url:3': 0.61; 'world.': 0.61; 'you.': 0.62; 'email addr:gmail.com': 0.63; 'kind': 0.63; 'anything.': 0.68; 'received:2': 0.84
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Mark Lawrence <breamoreboy@yahoo.co.uk>
Subject Re: array/list of sockets
Date Sat, 26 Oct 2013 23:01:06 +0100
References <f31c18ac-ef3b-42b9-90cd-c0ef4bd80c06@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host host-2-98-201-160.as13285.net
User-Agent Mozilla/5.0 (Windows NT 6.1; rv:24.0) Gecko/20100101 Thunderbird/24.0.1
In-Reply-To <f31c18ac-ef3b-42b9-90cd-c0ef4bd80c06@googlegroups.com>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.1616.1382824883.18130.python-list@python.org> (permalink)
Lines 30
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1382824883 news.xs4all.nl 15870 [2001:888:2000:d::a6]:47971
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:57671

Show key headers only | View raw


On 26/10/2013 22:41, theelder777@gmail.com wrote:
> 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']

This is a list of Python strings, not an array, not sockets.

>
> 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.
>

See this http://docs.python.org/3/library/socket.html#example

-- 
Python is the second best programming language in the world.
But the best has yet to be invented.  Christian Tismer

Mark Lawrence

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

array/list of sockets theelder777@gmail.com - 2013-10-26 14:41 -0700
  Re: array/list of sockets Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-10-26 23:01 +0100
  Re: array/list of sockets Johannes Findeisen <mailman@hanez.org> - 2013-10-26 23:59 +0200
  Re: array/list of sockets theelder777@gmail.com - 2013-10-26 15:15 -0700
    Re: array/list of sockets Chris Angelico <rosuav@gmail.com> - 2013-10-27 09:31 +1100
    Re: array/list of sockets Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-10-26 23:33 +0100
  Re: array/list of sockets theelder777@gmail.com - 2013-10-26 15:42 -0700
    Re: array/list of sockets Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-10-27 00:03 +0100
      Re: array/list of sockets theelder777@gmail.com - 2013-10-26 16:17 -0700
        Re: array/list of sockets mm0fmf <none@mailinator.com> - 2013-10-27 00:26 +0100
        Re: array/list of sockets Chris Angelico <rosuav@gmail.com> - 2013-10-27 10:27 +1100
        Re: array/list of sockets Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-10-27 00:36 +0100
          Re: array/list of sockets theelder777@gmail.com - 2013-10-26 16:56 -0700
            Re: array/list of sockets Chris Angelico <rosuav@gmail.com> - 2013-10-27 11:05 +1100
        Re: array/list of sockets rurpy@yahoo.com - 2013-10-26 21:29 -0700
        Re: array/list of sockets rusi <rustompmody@gmail.com> - 2013-10-27 01:53 -0700

csiph-web