socket.error : [errno 10048] and view PID process number and port number

A socket program recently written in python has run with an error:
socket.error: [Errno 10048] normally each socket address (protocol/network address/port) is allowed only once
After searching, it is found that this prompt appears when the port is in conflict. The possible reason is that after a Socket is created in the server program and a port is opened, the Socket is not closed at the end of the program. Therefore, this error prompt will appear next time the program is started.
1, at the end of the server program to close the Socket
2. Or change the port number
3. Restart the machine
Win7 system quickly check the port number and pid process number:
1. Press Win+R key, enter CMD, open the command line.
2. Enter netstat -aon|findstr in the CMD window to indicate the port number you want to see. Take netstat -aon|findstr 80 as an example:
3. As can be seen from the figure below, there is a program occupying port 80. On the far right is the process ID occupying the program: 2996;

4. Knowing the process ID, we just need to find out which program 2996 is. Continue typing the following command: tasklist|findstr “2996”, where 2996 is the previous process ID.
closes the corresponding process

    taskkill /F /IM httpd.exe  

View port status

netstat -aon

Read More: