[Tutor] socket / over network

Kim Hawtin kim.hawtin at adelaide.edu.au
Mon Apr 7 04:30:48 CEST 2008


Hi Nathan,

Nathan McBride wrote:
> Alan Gauld wrote:
>> "Nathan McBride" <nomb85 at comcast.net> wrote
>>> I'm pretty tired of the lame backup solution we have at work.
>>> Could anyone point me to a (more or less newbieish) example of how
>>> to
>>> have python open a socket on one box and get data from it, then have
>>> another
>>> box write to it over the network?
>> For a very simple example of using a socket you could try the
>> Network Programming topic in my tutorial.
> 
>> There is also a HowTo or Topic guide on the Python web site
>> that gives a more detailed example.
> 
>> That having been said, backups are usually best done using
>> OS tools or if you must roll your own then using ftp or similar
>> as a file transfer mechanism rather than trying to send a
>> bytestream over a socket. ftp can handle broken connections
>> etc more easily. Detecting and fixing errors over a socket
>> stream is non trivial and for backups is pretty much essential!!
> 
> Going off of wha tyou said, if I choose to use ftp, is there a way i
> could do everything from within python including the server to get the
> files?  Is there like a ftp module for python to help in the passing of
> the files between the computers?

There are number of problems with FTP around security and firewalls, etc.

This might be overkill, but perhaps you could use Twisted with SSH/SCP to get
files around?

See; [Twisted-Python] Twisted SCP
  http://twistedmatrix.com/pipermail/twisted-python/2005-December/012180.html

Perhaps using Rsync and SSH might be more appropriate;
 http://www.howtoforge.com/rsync_incremental_snapshot_backups

regards,

Kim
-- 
Operating Systems, Services and Operations
Information Technology Services, The University of Adelaide
kim.hawtin at adelaide.edu.au


More information about the Tutor mailing list