How to fix 'The requested address is not valid in its context' for local ip

1.4k Views Asked by At

I'm attempting to add an Open Sound Control (UDP) listener to a python program, but I keep getting the error "OSError: [WinError 10049] The requested address is not valid in its context". The program works when accessing my own ip, but not when I attempt to add a listener to a different ip. I know I cannot acces external ip's but the computer I am trying to access is on the same network.

I have tried different OSC listeners (pyOSC, python-osc) but they don't work. However, a OSC program I have installed (OSCwidgets) is able to access the other computer, so I know it is just the python program that does not work.

Here is the file I am working with (not including the error handlers):

from OSC import OSCServer, OSCClient, OSCMessage
import types

server = OSCServer(("192.168.86.34", 8000))

def test_callback(path, tags, args, source):
    if path=="/test":
        print("pyOSC Receive: " + str(path) + " = " + args[0])

server.addMsgHandler("/test",test_callback)

while True:
    server.handle_request()

The program should simply print the OSC packet received from the specified ip. The full error that occurs is below.

Traceback (most recent call last):
  File "C:/Users/red4d/Documents/GitHub/ETC-Eos-OSC-Controller/pyOSCreceivetest.py", line 5, in <module>
    server = OSCServer(("192.168.86.34", 8000))
  File "C:\Users\red4d\AppData\Local\Programs\Python\Python36-32\lib\site-packages\OSC.py", line 1716, in __init__
    UDPServer.__init__(self, server_address, self.RequestHandlerClass)
  File "C:\Users\red4d\AppData\Local\Programs\Python\Python36-32\lib\socketserver.py", line 453, in __init__
    self.server_bind()
  File "C:\Users\red4d\AppData\Local\Programs\Python\Python36-32\lib\socketserver.py", line 467, in server_bind
    self.socket.bind(self.server_address)
OSError: [WinError 10049] The requested address is not valid in its context
0

There are 0 best solutions below