Skip to main content

Python - Network Programming

The threading module in Python's standard library is capable of handling multiple threads and their interaction within a single process. Communication between two processes running on the same machine is handled by Unix domain sockets, whereas for the processes running on different machines connected with TCP (Transmission Control Protocol), Internet domain sockets are used.

Image

Python's standard library consists of various built-in modules that support interprocess communication and networking. Python provides two levels of access to the network services. At a low level, you can access the basic socket support in the underlying operating system, which allows you to implement clients and servers for both connection-oriented and connectionless protocols.

Python also has libraries that provide higher-level access to specific application-level network protocols, such as FTP, HTTP, and so on.

Network Protocols and Corresponding Python Modules​

ProtocolCommon FunctionPort NoPython Module
HTTPWeb pages80httplib, urllib, xmlrpclib
NNTPUsenet news119nntplib
FTPFile transfers20ftplib, urllib
SMTPSending email25smtplib
POP3Fetching email110poplib
IMAP4Fetching email143imaplib
TelnetCommand lines23telnetlib
GopherDocument transfers70gopherlib, urllib