Re: Scket connection to server



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):

import socket
s = socket.Socket()
s.connect((10.214.109.50, 29999))
s.send("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.

Steve
.



Relevant Pages

  • Re: why are docs so out of date?
    ... For example, in the UDPSocket class, there is no mention of the send ... UDP socket class ... Binds the socket to port on host. ...
    (comp.lang.ruby)
  • Re: pickle problem
    ... lib "socket" class, which apparently uses slots. ... self.sock.connect((host, port)) ... # pickle self as a (host, ... some child processes from the parent and use IPC to send the ...
    (comp.lang.python)
  • Re: Socket bind: Port-Wiederverwendung
    ... Wie muss ich denn den Socket richtig löschen, ... Port anzugeben, ... Es muss wirklich immer der gleiche Host sein! ... Das .Net Framework stell entsprechende Klassen ...
    (microsoft.public.de.german.entwickler.dotnet.csharp)
  • Re: Testing for Internet Connection
    ... Troeger Thomas wrote: ... import socket, struct ... Check for connectivity to a certain host. ... sock.connect((host, port)) ...
    (comp.lang.python)
  • Buffer size when receiving data through a socket?
    ... I wrote some pretty basic socket programming again, but I'm still confused about what's happening with the buffer_size variable. ... Here are the server and client programs: ... address = (host, port) ...
    (comp.lang.python)