In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly shows you the "excellent method of socket Chinese garbled code". The content is simple and clear. I hope it can help you solve your doubts. Let the editor lead you to study and learn this article "excellent method of socket Chinese garbled code".
The solution to Chinese garbled in socket is to use "new OutputStreamWriter (client.getOutputStream ()," UTF-8 "...") to read and write buffers. The code is fine.
Operating environment of this article: windows7 system, DELL G3 computer
What about the Chinese garbled code in socket?
Solution of Chinese garbled code in Socket communication
Use these two lines of code for reading and writing to the buffer:
PrintWriter out=new PrintWriter (new OutputStreamWriter (client.getOutputStream (), "UTF-8"), true); BufferedReader msg=new BufferedReader (new InputStreamReader (client.getInputStream (), "UTF-8"))
Related introduction:
Socket (Socket) is the cornerstone of communication and the basic operation unit of path communication that supports TCP/IP protocol. The socket can be regarded as the endpoint of double communication between processes between different hosts, which constitutes the programming interface within a single host and between the whole network. Sockets exist in the communication domain, which is an abstract concept introduced to deal with general thread communication through sockets. Sockets usually exchange data with sockets in the same domain (data exchange may also cross domain boundaries, but some interpreter must be executed), and various processes use the same domain to communicate with each other using the Internet protocol suite.
Socket (socket) can be regarded as the endpoint in the respective communication connection when two network applications communicate, which is a logical concept. It is the API (application programming interface) of inter-process communication in the network environment, and it is also a communication endpoint that can be named and addressed. each socket in use has its own type and a connected process. During communication, a piece of information to be transmitted by one of the network applications is written into the Socket of its host, and the Socket sends the information to the Socket of another host through the transmission medium connected to the network interface card (NIC), so that the other party can receive the information. Socket is a combination of IP addresses and ports that provide a mechanism for sending packets to application layer processes.
The above is all the contents of this article entitled "the Best way to garble socket Chinese". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
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.