[Chicago] Socket question

Kumar McMillan kumar.mcmillan at gmail.com
Fri Dec 4 00:00:55 CET 2009


On Thu, Dec 3, 2009 at 3:02 PM,  <deadwisdom at gmail.com> wrote:
> You can't be reading from both at the same time, though. It blocks while
> it's reading. You'll have to create a new thread or use Eventlet
> (http://eventlet.net/), which is currently my favorite python library ever.
> Damn is it cool.

Neat!  So I guess a better answer is use eventlet's green sockets to
make it appear as though you are simultaneously reading from two
sockets: http://eventlet.net/doc/basic_usage.html#socket-functions

>
> On Dec 3, 2009 10:00am, Kumar McMillan <kumar.mcmillan at gmail.com> wrote:
>> On Thu, Dec 3, 2009 at 9:03 AM, perlsyntax
>>
>> fasteliteprogrammer at gmail.com> wrote:
>>
>> > Is there away in python i can connect to a server in socket to two
>> > servers
>>
>> > at the same time or can't it be done?
>>
>>
>>
>>
>>
>> it's just an object, you can instantiate as many as you want.  See:
>>
>> http://docs.python.org/library/socket.html#example
>>
>>
>>
>> then modify with:
>>
>>
>>
>> PORT = 50007              # Arbitrary non-privileged port
>>
>> s1 = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
>>
>> s1.bind(('creditcardnumbers.ru', PORT))
>>
>> s2 = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
>>
>> s2.bind(('customeraddresses.ru', PORT))
>>
>> _______________________________________________
>>
>> Chicago mailing list
>>
>> Chicago at python.org
>>
>> http://mail.python.org/mailman/listinfo/chicago
>>
> _______________________________________________
> Chicago mailing list
> Chicago at python.org
> http://mail.python.org/mailman/listinfo/chicago
>
>


More information about the Chicago mailing list