The error you’re encountering (OSError: [WinError 10048] Only one usage of each socket address (protocol/network address/port) is normally permitted) indicates that the port you are trying to bind to is already in use. This can happen if another instance of your application is already running or if another application is using the same port.
Here are steps to resolve this issue:
Ensure that there are no other instances of your application or any other applications using the same port.
- On Windows:
- Open Command Prompt and run the following command to find processes using the port:
netstat -aon | findstr :<port>
- Replace
<port> with the port number you are trying to bind to.
- Note the PID (Process ID) of the process using the port.
- You can then terminate the process using:
Replace
<PID> with the actual Process ID.
If stopping the process using the port is not an option, you can change the port number your application uses.
- Open your script (
gptUnity_19072024_CW.py) and locate where the port is defined.
- Change the port number to an available one.
server = osc_server.ThreadingOSCUDPServer((args.local_ip, <new_port>), disp)
Replace <new_port> with an available port number.
You can modify your script to handle the case where the port is already in use and try a different port automatically.
Here’s an example modification to handle this:
from pythonosc import dispatcher, osc_server
parser = argparse.ArgumentParser()
parser.add_argument("--local_ip", default="127.0.0.1", help="The ip to listen on")
parser.add_argument("--local_port", type=int, default=5005, help="The port to listen on")
args = parser.parse_args()
disp = dispatcher.Dispatcher()
disp.map("/filter", print)
server = osc_server.ThreadingOSCUDPServer((args.local_ip, port), disp)
print(f"Serving on {args.local_ip}:{port}")
print(f"Port {port} is in use. Trying the next port...")
if __name__ == "__main__":
This script will automatically try the next port number if the specified one is in use.
Sometimes, ports can be held by processes that are not properly closed. Restarting your computer can release such ports.
By following these steps, you should be able to resolve the issue and run your application without encountering the port already in use error.