Socket question

D'Arcy J.M. Cain darcy at druid.net
Thu Dec 3 11:07:14 EST 2009


On Thu, 03 Dec 2009 09:45:19 -0600
perlsyntax <fasteliteprogrammer at gmail.com> wrote:
> On 12/03/2009 09:28 AM, exarkun at twistedmatrix.com wrote:
> > On 02:52 pm, 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?
> >
> > I'm not sure what you're asking.  Can you clarify?
> >
> > Jean-Paul
> I just want to know could it be done makeing my own socket tool that 
> connect to two server at the same time.And what link do i need to look at?

Repeating the question won't clarify it any more.  Post some code, even
pseudo code, to show what you are trying to do and be clear about what
you expect it to do.

Let me start you out.

from socket import *

def MyConnection(host, port):
    s = socket(AF_INET, SOCK_STREAM)
    s.connect((host, port))
    return s

s1 = MyConnection(host1, port1)
s2 = MyConnection(host2, port2)

There, that gives you access to two remote servers in one tool.  That's
what you asked for.  I am sure that what you really need is something
else so expand on this example so that we can see what you really want. 

-- 
D'Arcy J.M. Cain <darcy at druid.net>         |  Democracy is three wolves
http://www.druid.net/darcy/                |  and a sheep voting on
+1 416 425 1212     (DoD#0082)    (eNTP)   |  what's for dinner.



More information about the Python-list mailing list