The solution to the Chinese garbled socket is to use the "new OutputStreamWriter(client.getOutputStream(),"UTF-8"..." code to read and write the buffer.
The operating environment of this article: windows7 system, DELL G3 computer
What should I do if the Chinese socket is garbled?
Socket communication Chinese garbled code solution
Use these two codes to read and write 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 , is the basic operating unit that supports road communication of the TCP/IP protocol. Sockets can be regarded as endpoints for dual communication between processes between different hosts. It constitutes the programming interface within a single host and across the entire network. Socket Words exist in the communication domain, which is an abstract concept introduced to handle general thread communication through sockets. Sockets usually exchange data with sockets in the same domain (data exchange may also cross domains boundaries, but at this time some kind of interpreter must be executed), and various processes use this same domain to communicate with each other using the Internet protocol cluster.
Socket (socket) can be regarded as When two network applications communicate, each endpoint in the communication connection is a logical concept. It is an API (Application Programming Interface) for inter-process communication in a network environment, and it is also a communication that can be named and addressed. Endpoint, each socket in use has its type and a process connected to it. During communication, one of the network applications writes a piece of information to be transmitted into the Socket of the host where it is located, and the Socket communicates with the network interface card ( The transmission medium connected to the NIC) sends this information to the Socket of another host so that the other party can receive this information. Socket is a combination of IP address and port, which provides a mechanism for transmitting data packets to the application layer process.
For more related knowledge, please visit the FAQ column!
The above is the detailed content of What to do if the Chinese socket is garbled?. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

WebStorm Mac version
Useful JavaScript development tools

Atom editor mac version download
The most popular open source editor

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software