Support for multiple address families in Python
Among them, the most common of the first Berkeley sockets is Af_unix,
The sockets in Linux are Af_netlink,
Another feature for Linux (added in Python 2.6 ) is the support for transparent interprocess communication (TIPC) On.TIPC allows machines in a cluster of computers to communicate with each other without using IP -based addressing. Python on TIPC 's support is presented in the AF_TIPC family Way.
< Span class= "Fontstyle2" > family name af_inet address family: < Span class= "Fontstyle2" > Internet. Another address family af_inet6 for 6 version of the Internet Protocol (ipv6
< Span class= "Fontstyle2" > 1. Creating sockets
to create a socket, you must use the Socket.socket () function, which generally has the following syntax.
sockets (Socket_family, Socket_type, protocol=0)
where socket_family is Af_unix or af_inet (as mentioned earlier), Socket_type is Sock_stream
or Sock_dgram (as mentioned earlier). Protocol is usually omitted and defaults to 0.
therefore, in order to create a TCP/IP socket, you can call Socket.socket () in the following way.
Tcpsock = Socket.socket (socket.af_inet, socket. SOCK_STREAM)
Similarly, in order to create a UDP/IP socket, the following statement needs to be executed.
udpsock = Socket.socket (socket.af_inet, socket. SOCK_DGRAM)
/span>
Tips: Using from Socketimport *, you can write Udpsock = socket (socket.af_inet, socket) directly. SOCK_DGRAM), do not add the module name socket before each function name.
Socket built-in methods
In general, the simple standard process is:
Network programming in the 6.python