Introduction to Network Programming

Internet Introduction to Programming:

What is network programming:

  Generally refers to a computer network in the Internet, is composed by a plurality of computers connected to each other through a network cable or other media,

  Web-based applications written in the programming process called network

 

So why learn network programming:

  We already know that computer, operating system, application composition, with these three elements, you can run a number of applications on your computer, such as playing cards to play, what to sweep mine clearance, can only play single games

  If you want to play with other computers, you have to let your computer and other computers can transfer data to each other

Learning network programming is to learn to use the network to transmit data to each other with another computer, to develop applications that support a network of communication, so that you can stay at home also can know the world affairs

 


Software development framework:

  C / S architecture:

Learning network programming is to access data on another computer over a network, it will surely need at least two computers running on one computer to access the shared data to be placed for the sharing of data and programs, another computer program data,

 

We called party to provide data server (server), the party called client access to data (client)

This is the C / S structure  

Look at the video you need to install on the computer to see the video of the program. For example, Tencent video, it is the client, Tencent's server program running room in the Tencent video, so it is also a C / S architecture program

Further web browser can access data on the server, known as B / S, which is essentially C / S but the client browser

to sum up:

  C / S architecture (client / server)

  c: Client

  s: server

  B / S structure (browser / server)

  b: Browser

  s: server

Note: The nature of the structure is bs cs structure

Cs mobile terminal looks structure is fire, in fact, has been the rise of the bs,

Micro-channel Alipay are doing one thing: a unified interface

Server: 24-hour service

Client: When did want to experience the service, the server went looking for your favorite service

 

 

Network communication protocols:
two computers want to communicate, you must have two basic elements

1. The physical connection media, including cable, radio, optical fiber,

2. Communication protocol

1. The physical connection medium

For example, to make a phone call the phone must be connected to telephone lines, to reach another telephone current along the telephone line, the telephone line is the physical medium

2. Communication protocol:

Protocol is the standard, we all have to follow the same standards for proper communication exchange

For example, two people to exchange, must speak a language understood by both sides, or you speak your language, I said my language, the two sides do not understand, people have to say in order to achieve smooth communication unified language >>> English

 

To communicate between the remote computer and the computer ** In addition to the physical connection media than required 
set of common standards / protocols

of the OSI model:
application layer
presentation layer
session layer
transport layer,
network layer,
data link layer,
a physical connection layer

for convenience in mind, simplified bit, five becomes OSI model
application layer
transport layer
network layer
a data link layer
the physical connection layer

1. the physical connection layer:
  based on electrical signal transmission 010,101,001 binary data

2. data link layer
  1 the provisions of the grouping of the electrical signal
  2. the provisions of any Internet-connected computer must have a network card,
  each piece is engraved with a unique card on top of the world number
  12 hexadecimal
    top six manufacturers are numbered
    after six is the number line
  we call the 12-digit tube mac address
  Note: the above two points combined into 'Ethernet protocol'

3. network layer:
  
IP protocol 
provides for as long as the computer connected to the Internet must have an IP address
ip address Features: dotted decimal
ip address minimum: 0.0.0.0
ip address maximum: 255.255.255.255
ip address is currently available in two versions: IPV4 IPV6 (due IPV4 indicates that the computer has enough existing launch the so IPV6 version)
IP address is dynamically allocated
4. Transport Layer 
TCP / UDP protocols are based on a port operating
port (Port)
In fact, between the computer and the communication between the computer applications and applications on a computer 
port: is used to identify an application on a computer
  port number ranges of: 0 to 65535
  Note: these are 0 to 1024 operating system default port number
  recommendation: use the port after 8000
  MySQL default port: 3306 
  Redis Default Port: 6379
  Django default port: 8000
  the Flask default port: 5000
port number is dynamically assigned, for example, start qq assigned first port number is 8989, the qq shut down the port number might start again changed
Summary: 
ip address: is used to uniquely identify a computer connected to the Internet
port port: used to uniquely identify an application starts on a computer that
ip + port: a unique identifier to access the Internet on a computer a reference to the program start


5. application
data transmission
  TCP protocol
    loss protocol, reliable protocol
    based on the TCP protocol communications, required to establish a two-way channel
Why is reliable protocol, because reliable data transmission tcp reason is that he has a feedback mechanism,
because the transmission of data the party must wait for the response of the recipient, will delete the data in memory,
there is no response, then is not deleted, will from time to time on the hair once, wait until the response will have to delete the data in memory


three-way handshake:

Three-way handshake process is actually really confirm my hair you receive, you can receive my hair, so as to ensure the reliability of data transmission,

Link is a virtual concept, does not actually exist, as long as the three-way handshake success means that the connection is established!

The problem is indeed to protect data transmission when the three-way handshake is reliable, then the data transfer handshake to how to ensure success?

TCP protocol requires that after sending data, the other party must receive the reply message to confirm successful transmission of data, within a period of time if no reply is received, it will automatically resend, if the number of retries too, said links may have been interrupted!


Four wave:


Four waving aim is to ensure that the data transmission between the two sides has been completed, also in order to ensure data integrity

Four waving the middle of the two-step merger is not, because the server needs to check if there are unpublished play data

to sum up

The advantage is clear: to ensure that the data transmission is complete

Disadvantages: As always need to confirm the information transmission, resulting in reduced transmission efficiency

Scene: used must ensure data integrity of the scene, such as text information, payment information, and so on!




  

 

 

 

 

Guess you like

Origin www.cnblogs.com/zahngyu/p/11311687.html