Python network programming - new FTP and socket level examples
Archive - Originally posted on "The Horse's Mouth" - 2013-05-14 17:31:48 - Graham EllisThese days, it's the exception rather than the rule to write low level network code within your applications - and during today's Intermediate Python course, I wrote an example showing an FTP connection to retrieve data using ftplib. The first example is [here] - grabbing a file, saving it locally via a callback.
A second version, using a thread to allow the FTP connection to be running while the main program is getting on with something else, is [here].
If you do need to program a socket directly, yes, you can do so. I've revised / refreshed myself into that - [here] is a demonstration from first principles of picking up a header from a web server. Lots of extra checking to do really, but the examples show the principles and you can build from there.