Python Core (i)

Source: Internet
Author: User

---restore content starts---

0x01 Socket First Family Af_unix

Address family: Addresses Family:unix file-based sockets

Type II Af_inet

Address family: Internet

Type III: Af_netlink (no connection type)

Allows the use of the BSD socket user interface for IPC between user-level and kernel-level code.

0X02 connection-oriented sockets and non-connected sockets

(1). Connection-oriented sockets.

Communication provides serialization, reliable, and non-repeatable data delivery. Information can be split into multiple fragments, and each socket is guaranteed to reach its destination. Implement this type of primary protocol: TCP.

(2). For non-connected sockets

Contrary to the nature of the connection-oriented sockets. Low cost. Udp.

0X03 socket () module function

Sockets (Socket_family, Socket_type, protocol=0)

  

Create a TCP/IP socket

Tcpsock = Socket.socket (socket.af_inet, socket. SOCK_STREAM)

Create UDP/IP sockets

Udpsock = Socket.socket (socket.af_inet, socket. SOCK_STREAM)

Using the FROM socket import * allows you to introduce the socket attribute into the namespace, which shortens the code.

Tcosock = socket (af_inet, SOCK_STREAM)

---restore content ends---

Python Core (i)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.