[LAD] python-osc udp_client.UDPClient() - How do I figure out the reply-to IP?

Len Ovens len at ovenwerks.net
Wed Jul 6 15:29:56 UTC 2016


On Wed, 6 Jul 2016, Christopher Arndt wrote:

> Am 06.07.2016 um 01:38 schrieb Kevin Cole:
>> In pythonosc (https://pypi.python.org/pypi/python-osc) after
>> connecting with udp_client.UDPClient(...) from a "client", how can I
>> detect the IP to respond to in the "server"?
>
> Normally, with UDP servers, you'd use socket.recvfrom() to read the data from 
> the client and get its address.

In liblo, the client's address (url form includes protocol,ip,port) is a 
part of the received message which is very handy. That does not seem to be 
the case here. I also see that, at least in the examples, the word address 
is used for the OSC path which is even more confusing.

However, looking at 
https://github.com/attwad/python-osc/blob/master/pythonosc/osc_server.py

There is a class OSCUDPServer and it includes a call verify_request() with 
one of the parameters being client_address. Maybe drop a print command 
into that call that prints out whatever client_address is stored as. This 
will tell you if you have the information you need at that point. (IP and 
port) If so you may be able to expand the handlers by adding this 
parameter to the calls you need so that this address is exposed or you may 
be able to use this parameter (or structure) directly.

Anyway, the info is there. and it does seem to get passed to some 
places...

this bit in the same file as above: (line 168)
def datagram_received(self, data, unused_addr):
seems to indicate someone has thought the address should be used for 
something but that is is not at this time. I think expanding this python 
library would be the easiest route. (then push that expansion back for 
inclusion for others to use)

Now I know why I don't use python... I find it quite difficult to follow.

--
Len Ovens
www.ovenwerks.net



More information about the Linux-audio-dev mailing list