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


Groups > comp.lang.python > #57671

Re: array/list of sockets

From Mark Lawrence <breamoreboy@yahoo.co.uk>
Subject Re: array/list of sockets
Date 2013-10-26 23:01 +0100
References <f31c18ac-ef3b-42b9-90cd-c0ef4bd80c06@googlegroups.com>
Newsgroups comp.lang.python
Message-ID <mailman.1616.1382824883.18130.python-list@python.org> (permalink)

Show all headers | 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