In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces "what is Socket programming". In daily operation, I believe many people have doubts about what is Socket programming. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful for you to answer the doubts about "what is Socket programming?" Next, please follow the editor to study!
What is Socket?
Socket, which means "socket, Jack" in English, is generally called a socket, which is used to describe the IP address and port. The data communication between different programs can be realized.
Socket originated from Unix, and one of the basic philosophies of Unix is "everything is a file", which can be operated in the "Open open- > read and write write/read- > close close" mode. Socket is an implementation of this pattern, and the Socket data transmission of the network is a special kind of I _ socket and also a kind of file descriptor. Socket also has a function call similar to opening a file: Socket (), which returns an integer Socket descriptor, and subsequent connection establishment, data transfer, and other operations are implemented through this Socket.
In TCP/IP protocol, "IP address + TCP or UDP port number" uniquely identifies a process in network communication. "IP address + port number" corresponds to a socket. Each of the two processes that want to establish a connection is identified by a socket, so the socketpair composed of the two socket uniquely identifies a connection. Therefore, Socket can be used to describe the one-to-one relationship of network connections.
There are two common types of Socket: streaming Socket (SOCK_STREAM) and Datagram Socket (SOCK_DGRAM). Streaming is a kind of connection-oriented Socket for connection-oriented TCP service applications; Datagram Socket is a kind of connectionless Socket corresponding to connectionless UDP service applications.
Network application design pattern
Cpact S model
Traditional network application design pattern, client (client) / server (server) mode. Clients and servers need to be deployed at both ends of the communication to complete data communication.
BDUBERS model
Browser (Browser) / server (Server) mode You only need to deploy the server on one side, while the other end uses a browser that is configured by default for each PC to complete the data transfer.
Advantages and disadvantages
For the Cpact S model, its advantages are obvious. The client is located on the target host to ensure performance and cache data locally on the client, thus improving the efficiency of data transmission. Moreover, generally speaking, client and server programs are created by a development team, so the protocols used between them are relatively flexible. It can be tailored and customized according to requirements on the basis of standard protocols. For example, the communication protocol adopted by Tencent is a modified and cut version of the ftp protocol.
Therefore, traditional network applications and larger network applications are preferred to develop based on Cpact S mode. For example, the well-known online game World of Warcraft. 3D screen, a large amount of data, the use of Cpact S mode can be in advance in the local data cache processing, so as to improve the look and feel.
The shortcomings of Cpact S mode are also prominent. Because both the client and the server need a development team to complete the development. The workload will increase exponentially and the development cycle will be longer. In addition, from the user's point of view, the client needs to be installed on the user's host, which poses a threat to the security of the user's host. This is also an important reason why many users do not want to use Cramp S mode applications.
Therefore, in the process of development, the choice of patterns is determined by the above characteristics. Choose the application design pattern according to the actual needs.
At this point, the study of "what is Socket programming" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.