current position：Home>Server socket + Android socket can only send a message once after connecting. The second sending does not respond. You need to reconnect the socket and solve it
Server socket + Android socket can only send a message once after connecting. The second sending does not respond. You need to reconnect the socket and solve it
2022-02-03 00:13:28 【CSDN Q & A】
Server use serversocket, The Android terminal uses socket Connect , You can connect to the server , But you can only send a message once , After that, the server can't receive the message ,debug Only for the first time dis.readUTF() Blocking waiting clients , If you use dis.readLine() Method prints the message for the first time , There will be no obstruction in the back , Print all the time null.
Android client code
Refer to the answer 1：
The connection with the server needs to be maintained through heartbeat ,socket Disconnection often occurs So you need to send a heartbeat After receiving the heartbeat, the back end replies to the front end , Prove that the connection is normal .
Refer to the answer 2：
author[CSDN Q & A],Please bring the original link to reprint, thank you.
The sidebar is recommended
- A simple code to solve it
- What's wrong with this code that skips uppercase letters and only outputs lowercase letters?
- First clear the content in the text, and then add content in the?
- Problems about Jason object in Java front end
- Unreal 4 code version failed to compile and did not move anything. It was downloaded and compiled directly in GitHub. Only one project failed. Please solve it.
- HTML enters jump for the first time and does not jump for the second time.
- How is the progress bar of Python multi process displayed on the UI?
- The complete link and operation method of tiktok draining to the website need to be effective
- Simulink simulates the vector control (FOC) of permanent magnet synchronous motor and starts the oscillation problem
- Dynamic linked list failed to use bubble sorting
guess what you like
Remote connection redis problem
Table a and table B, after changing sides, use explain. The result is a little unexpected. Why
What's the matter with entering an even number in idea to get "= number"?
How can C language use a function to find characters and replace them
Several problems in introductory learning!
Input two strings STR1 and STR2, connect the string STR1 to STR2, and output STR1 and its length (prompt: string connection function: strcat (STR1, STR2) string length calculation function: strlen (STR))
Using pointer variable: input a one-dimensional array from the keyboard and return one-dimensional array containing only odd numbers and one-dimensional array containing only even numbers respectively. The data in the array is sorted from small to large.
Maze game, maze initialization, specify the entrance or exit position, and print the maze.
The notebook may normally accept the sent information, but it can't load the web page. The network diagnosis and treatment shows the results in the figure below. How should I solve it?
How to use stu method to input student names and grades in pyton and store them in the list
- Car interaction code in Android studio
- If you enter the title of a book, the length of each title is no more than 100, and the books are sorted in ASCII order from small to large. Enter the number of book titles indefinitely until the end of the document. Sort the string from small to large ac
- Python selenium loading is slower than opening the web card normally. Is there any solution
- When the database connection is normal, it is impossible to add, delete, modify and query the data in the database
- How to realize NS3 traffic load distribution
- How to enter the grades of each subject? Do you need a two-dimensional array for each subject
- Please answer what this is
- How to define and initialize structures in. H
- In C language, the input content is larger than the defined array, but can it be output?
- The running result is not expected (c + +)
- matlab . Image pixel processing
- The process of solving these more than 2000 functions through subs is too slow
- Longest common prefix, binary search problem
- Basic HTML5 code table and usage
- Error is reported after Vue project is started. Please ask for help
- How can I open the database in the examinee's folder for computer level 2 MySQL test questions?
- The following program (function) deletes the characters exactly the same as the string S2 in the string S1, such as S1: China S2: in, and the result is cha
- Why NP The empty ((3,2)) element is not random?
- Why do you report an error? Find a solution
- Using C + + and pcap H and iphlpapi H. how to solve the problem?
- How can I fix the problem of uploading to idea
- com. fasterxml. jackson. databind. Objectmapper throw exception
- What is the reason and how to solve it
- Preparestatement of javajdbc
- int x=8,y=12,z=14 ; x++,y=z++,z=++x; y=x%z- -; Find the value of XYZ
- Why is this the case when I access the PHP test program under localhost in MacOS?
- Why should this code be int & n instead of int n? In C + +, under what circumstances do you need to be int & n
- The redis session problem runs well locally. As soon as it arrives online, it crazy reports exceptions. It starts to report when it starts. And the function can be used normally
- Research on Professional Course Scheduling Based on nonlinear programming
- The question about C + +: that's it: include 'Einstein h'
- Sqlyog failed to import the database. I don't know what to do
- The Microsoft edge browser can only enter the address in the address bar and cannot search
- Why can't data be saved when text is written in this way?
- When the user logs in and out, a socket error is reported when he logs in again
- The website editor cannot be right-click pasted and cannot be used
- On the problem of multi-threaded ball taking and putting (language Java)
- Start the flume script and report an error in the generated log file: agent configuration for 'A1' has no configfilters
- What can reflect the professional quality of a yard farmer?
- Why is the returned hour, minute and second Nan
- Python, C problem - leap year judgment