Python network programming-socket, python Network Programming

Source: Internet
Author: User

Python network programming-socket, python Network Programming
1. TCP/IP

To understand socket, you must first familiarize yourself with the TCP/IP Protocol family, namely, the Transport Control Protocol/internetprotocol, defines the criteria for how a host connects to the Internet and how data is transmitted between them. Literally, TCP/IP is the combination of TCP and IP protocols, but in fact, the TCP/IP protocol refers to the entire TCP/IP protocol family of the Internet. Different from the seven layers of the ISO model, the TCP/IP protocol reference model classifies all TCP/IP series protocols into four abstraction layers:
Application Layer: TFTP, HTTP, SNMP, FTP, SMTP, DNS, Telnet, etc.
Transport Layer: TCP, UDP
Network Layer: IP, ICMP, OSPF, VPN, IGMP
Data link layer: SLIP, CSLIP, PPP, MTU
Each abstraction layer is built on the services provided by the lower layer and provides services for the higher layer. It looks like this
In TCP/IP, two Internet hosts are connected through two routers and corresponding layers. Applications on various hosts read from each other through some data channels.


2. socket Concept

Two programs on the network exchange data through a two-way communication connection. one end of the connection is called a socket. A socket is also called a "socket". It is used to describe the IP address and port. It is a communication chain handle. applications usually send requests to or respond to network requests through the "socket. Socket originated from Unix, and one of the basic philosophies of Unix/Linux is "Everything is a file". It is operated in open, read/write, and Close Modes for files, socket is an implementation of this mode on the network, that is, socket is a special file. The two programs use socket to interact with data through the "network". It is only responsible for two things: establish a connection and transmit data. At the same time, the socket follows the principle when sending and receiving data: when sending data, there will be receiving, sending and receiving must be equal!
Differences between file read/write and socket data sending and receiving
-The file module opens, reads, and closes a specified file.
-The socket module is used to open (CONNECT), read/write (send and receive), and close (disconnect) the socket between the server and the client)

Related Article

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.