Re: Scket connection to server
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.python archive

Re: Scket connection to server

From: Jp Calderone <exarkun@divmod.com>
Date: Thu Jun 30 2005 - 21:08:11 CEST

On Thu, 30 Jun 2005 18:39:27 +0100, Steve Horsley <steve.horsley@gmail.com> wrote:
>JudgeDread wrote:
>> hello python gurus
>>
>> I would like to establish a socket connection to a server running a service
>> on port 29999. the host address is 10.214.109.50. how do i do this using
>> python?
>>
>> many thanks
>>
>>
>
>Off the top of my head (so there could be errors):
>

There are a few:

>import socket
>s = socket.Socket()

s = socket.socket()

>s.connect((10.214.109.50, 29999))

s.connect(('10.214.109.50', 29999))

>s.send("Hello, Mum\r\n")

s.sendall("Hello, Mum\r\n")

>
>That should point you in the right direction, anyway.
>
>There is a higher level socket framework called twisted that
>everyone seems to like. It may be worth looking at that too -
>haven't got round to it myself yet.

Twisted is definitely worth checking out.

Jp
Received on Thu Sep 29 16:40:26 2005