Network Infrastructure study notes

Common network programming socket interface as follows:

socket interface for creating socket; bind: bind a socket to a local address and port, usually by the end of the service calls (the client directly from the general initiative to connect directly link service ends); listen: for open listening mode, TCP dedicated; accept: a link waits for a client, in the case of a general blocking state generated; connect: Middle link for client server, TCP is a special function; send: TCP function for transmitting data; recv: TCP dedicated to receiving data function; sendto: for transmitting data to the specified IP address and port, the function is dedicated UDP, instead of the TCP, it is to be noted. Each of the interface function as shown below:

 

souket interface functions List of Functions

Three elements Network Programming (IP address, port, and protocol):

Which, IP address is a unique identifier for each device in the network, the equivalent of our identity, as each individual network outages in the network are independent existence, generally can view their IP address IPconfig, of course, Since most of us are not just a computer network card now, so in the case of multiple network cards are connected to the router and are activated, IP address IPconfig's probably more than one, the number of general network card is active there are that many application state IP addresses, the results obtained using the windows ipconfig command mode is generally as shown below:

 
 

ipconfig example in the window contents

2. Overview Port number: The port is to uniquely identify each program on the device, each network program needs to bind a port number, data transfer time in addition to determine where to send the machine, but also made clear to which program , port numbers range from 0-65535, but when we write applications, are generally used more than 1024 ports, ports 1-1024 commonly referred to as system port, usually by the operating system takes up various programs, For example port 80 is occupied http, port numbers 21 and 22 are occupied by FTP and SFTP, 445 are generally occupied port printers.

3, network communication protocol: it simply is for data exchange in a computer network established rules, standards or conventions set; computer network for communication must be some conventions, i.e. the communication protocol, on the rate, the transmission code, the code structure, transmission control step, to develop an error control standards. Common communication protocol is TCP, IP protocols, but the TCP / IP protocol is not just about these two, the one described, there is not much to say.

The following hierarchical thinking and common communication protocols TCP and UDP protocols do simple explanation:

①: to the layered communication protocol: the formulation is in agreement, the agreement simplified node complex protocol (divided into a plurality of components, which then eventually combined to form a complete protocol); most common way is a complex hierarchy mode, i.e., the interlayer may be in communication with the upper layer can call the next layer, the next layer with the relationship does not occur, and the layers independently of each other, for the development and expansion of the system

②: UDP and TCP are two very important agreements

Ⅰ:UDP

1, connectionless-oriented, unsafe data, speed. Does not distinguish between the client and the server

2, the data, source and destination encapsulation into packets, without establishing a connection

3, no need to release resources at the end of transmitting data so fast

Ⅱ:TCP

1, connection-oriented (three-way handshake), data security, speed slightly lower

2, TCP protocol to communicate with two application processes: client, server

3, three-way handshake ways: with your service client initiates a request, the server responds to the request, the data transmission

4, the connection can be made large amount of data transmission, the transmission is completed, the need to release an established connection, inefficient.

Guess you like

Origin www.cnblogs.com/sharan-coco/p/12641831.html