Solution to port occupation in win10
During socket communication debugging, if the program does not end normally, a port occupied error will be reported when the program is restarted.
1. Find the occupied port
Solution: Press win + R and Enter cmd to open the console, and enter
Netstat-ano | findstr8080
Check the process that occupies port 8080. The result is as follows:
The chart shows that 8080 is occupied by a program with a process id of 5036.
2. Killing related processes through the Task Manager Method 1: Killing processes using the Task Manager
Open Task Manager-> View-> Select column-> check the PID option and return to task manager to view the corresponding pid and end the process.
Of course, the above method is sometimes difficult to use, that is, when there are many processes in the task manager, it is very troublesome to find the corresponding process, so there is another way to kill the process
Start the task manager, click the PID in the detail column to sort it by PID, and right-click the corresponding process to end the task.
Method 2: Use commands to kill Processes
1> first, find the process name corresponding to the process number.
Tasklist | findstr process number
Example: tasklist | findstr 3112
2> then kill the process according to the process name
Taskkill/f/t/im process name
Example: taskkill/f/t/im/javaw.exe