From the perspective of a programming language, a socket is an unsigned integer variable that identifies a communication process. The two processes communicate, always know this information: the ip address and port number of both parties, the protocol stack used for communication. Socket is bound to these things, the implementation of the socket can use the interface provided by Unix, you can also use the winSock provided by wIndows.
Socket for occasionsSocket is a network programming at the transport layer. It is generally used for applications that need to define the protocol of the application layer. If you have a mature application layer protocol, such as http, you can use jsp.php.asp or the .net framework. Development.
Socket advantages and disadvantagesPersonally think that the disadvantage is that you need to remember a lot of functions, the process is more complicated to remember.
How to use socketClient: You need to establish a socket first, then apply for a connection to the server. You need to know the ip and port number of the server, instead of specifying the client (the client will be assigned by os), start to read and write information after connecting to the server, and finally close. Socket.
Server: establishes a listening socket, binds the address and port number, then starts listening, waits for the client to connect, generates a response socket, handles the connection request, then reads and writes the information, closes the response socket, closes Listen for sockets.
Detailed socketSocket is a way of process communication, that is, calling some API functions of this network library to realize data exchange between related processes distributed on different hosts.
Several definitions:
(1) IP address: that is, the network address assigned to the local host according to the TCP/IP protocol. Two processes need to communicate, and any process must first know the location of the communication partner, that is, the IP of the other party.
(2) Port number: used to identify the local communication process. A local process will occupy a port number when communicating. Different process port numbers are different. Therefore, a port number that has not been accessed must be assigned before communication.
(3) Connection: refers to the communication link between two processes.
(4) Semi-correlation: A triple in the network can be used to uniquely mark a process globally: (protocol, local address, local port number) such a triple, called a semi-correlation, which specifies each half of the connection.
(4) Full correlation: A complete inter-network process communication needs to consist of two processes and can only use the same high-level protocol. That is to say, it is impossible to communicate with one end using the TCP protocol and the other end using the UDP protocol. Therefore, a complete inter-network communication requires a five-tuple to identify: (protocol, local address, local port number, remote address, remote port number) such a five-tuple, called a related (associaTIon), that is, two The same semi-correlation of the protocols can be combined into a suitable correlation, or fully specified to form a connection.
Client/server mode
In the TCP/IP network application, the main mode of interaction between the two processes of communication is the client/server (C/S) mode, that is, the client sends a service request to the server, and after receiving the request, the server provides corresponding Service. The client/server model is built based on the following two points:
(1) First, the cause of the establishment of the network is the hardware and software resources, computing power and information inequalities in the network, which need to be shared, thus creating a host with a large number of resources to provide services, and customers with fewer resources requesting a non-equivalent service.
(2) Secondly, the inter-network process communication is completely asynchronous. There is neither a parent-child relationship nor a memory buffer between the processes communicating with each other. Therefore, a mechanism is needed to establish a connection between processes that want to communicate, for both. Data exchange provides synchronization, which is TCP/IP based on client/server mode.
Service-Terminal:
The process is that the server first needs to start first and provide the corresponding service according to the request.
(1) opening a communication channel and informing the local host that it is willing to receive a client request at a port on a recognized address (eg, the FTP port may be 21);
(2) waiting for a client request to reach the port;
(3) When receiving a service request from the client, the request is processed and a response signal is sent. Upon receiving a concurrent service request, a new process is activated to process the client request (eg, fork, exec in UNIX systems). The new process processes this client request and does not need to respond to other requests. After the service is completed, the communication link between the new process and the customer is closed and terminated.
(4) Return to step (2) and wait for another customer request.
(5) Shut down the server
Client:
(1) Open a communication channel and connect to a specific port of the host where the server is located;
(2) Send a service request message to the server, wait and receive the response; continue to make the request.
(3) After the request ends, the communication channel is closed and terminated.
From the process described above, we know:
(1) The role of the client and server processes is asymmetric, so the code is different.
(2) The server process is generally started first. As long as the system is running, the service process persists until normal or forced termination.
On the premise of having mature motor design capabilities and high-precision process support capabilities (including automatic CNC metal processing technology, automatic high-speed precision motor stator and rotor punching production process lights), the low Servo Motor built by Kassel can be compatible with ac servo motors. The drive is perfectly matched to maximize the power and performance of the equipment, output unparalleled power density and motion control effects, simple and cost-effective.
Low Inertia Servo Motor,Low Inertia Motor,Low Inertia Servo Motor Control,Low Inertia Servo Motor Robot
Kassel Machinery (zhejiang) Co., Ltd. , https://www.kasselservo.com