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

2016-07-06 Thread Len Ovens

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

___
Linux-audio-dev mailing list
Linux-audio-dev@lists.linuxaudio.org
http://lists.linuxaudio.org/listinfo/linux-audio-dev


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

2016-07-06 Thread Kevin Cole
On Wed, Jul 6, 2016 at 3:01 AM, Christopher Arndt  wrote:

> I forgot: if you only have clients in the local network, you could also just
> send packets to the broadcast address (use ifconfig to look it up).

Oooo. This seems simplest of all.  "Me likey!" ;-)
___
Linux-audio-dev mailing list
Linux-audio-dev@lists.linuxaudio.org
http://lists.linuxaudio.org/listinfo/linux-audio-dev


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

2016-07-06 Thread Kevin Cole
The responses from everyone are improving my understanding... I think.
Thanks all.

On Wed, Jul 6, 2016 at 2:59 AM, Christopher Arndt  wrote:

> It's not uncommon for OSC software, that you have to specify client (a)
> address(es) in the server as well, since OSC, commonly using UDP as a
> transport, is only uni-directional, so to get bi-directional communication,
> every participant in an OSC communication has to be a server and a client.

This part, if I understand you correctly, I'm already doing. I'm
creating a poor emulator of the Symbolic Sound Paca DSP's OSC. The
idea is to send Paca-specific OSC messages to the emulator, and
receive Paca-specific OSC responses.

I have very limited access to the Paca and want to be able to continue
development when away from the machine. Paca, in addition to OSC,
speaks Bonjour / Zeroconf / Avahi.  I've set up a Raspberry Pi with a
known hostname and registered a Zeroconf service.  In my test code, I
query the network for the OSC zeroconf service, explicitly specifying
the permanent zeroconf name of the Pi, just as I do with the actual
Paca.  That works.

But the real, physical Paca figures out who called to it and responds
to the caller.  The caller has to use the fixed, permanent zeroconf
address of the Paca, but the Paca does not have a hardwired address
for who to respond to.
___
Linux-audio-dev mailing list
Linux-audio-dev@lists.linuxaudio.org
http://lists.linuxaudio.org/listinfo/linux-audio-dev


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

2016-07-06 Thread Francesco Ceruti

Il 06/07/2016 01:38, Kevin Cole ha scritto:

Hi,

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"?

If I explicitly supply the return IP in the server's
udp_client.UDPClient(...) call it works.  But I want the server to
listen for an incoming connection or call on a particular port and
figure out who sent it and reply to that IP.

I have no network-fu.

Thanx!
--
@ubuntourist
___
Linux-audio-dev mailing list
Linux-audio-dev@lists.linuxaudio.org
http://lists.linuxaudio.org/listinfo/linux-audio-dev


Hi,

Looking at python-os "osc-server.py" code, I've noticed that the client 
address (IP, Port) is left, when dispatching UDP request,
you can either use a custom version (like this 
), were the callbacks receive the request 
address (in the example, as second argument),
or if you can freely decide what to send to the server, the clients can 
send their address into the requests, like this:


msg = osc_message_builder.OscMessageBuilder(address="/MyAddress")
msg.add_arg("Value")
msg.add_arg("IP_ADDRESS")  # replace with the client address using for 
example " socket.gethostname()"

msg = msg.build()
client.send(msg)
___
Linux-audio-dev mailing list
Linux-audio-dev@lists.linuxaudio.org
http://lists.linuxaudio.org/listinfo/linux-audio-dev


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

2016-07-06 Thread Christopher Arndt

Am 06.07.2016 um 08:59 schrieb Christopher Arndt:

It's not uncommon for OSC software, that you have to specify client (a)
address(es) in the server as well, since OSC, commonly using UDP as a
transport, is only uni-directional, so to get bi-directional
communication, every participant in an OSC communication has to be a
server and a client.


I forgot: if you only have clients in the local network, you could also 
just send packets to the broadcast address (use ifconfig to look it up).


Chris
___
Linux-audio-dev mailing list
Linux-audio-dev@lists.linuxaudio.org
http://lists.linuxaudio.org/listinfo/linux-audio-dev


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

2016-07-06 Thread Christopher Arndt

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.


https://docs.python.org/3/library/socket.html#socket.socket.recvfrom

But it doesn't seem like pythonosc supplies the client's address to the 
dispatcher.



But I want the server to
listen for an incoming connection or call on a particular port and
figure out who sent it and reply to that IP.


It's not uncommon for OSC software, that you have to specify client (a) 
address(es) in the server as well, since OSC, commonly using UDP as a 
transport, is only uni-directional, so to get bi-directional 
communication, every participant in an OSC communication has to be a 
server and a client.


If you don't need a pure-Python library, I'd look at python-liblo.


Chris

___
Linux-audio-dev mailing list
Linux-audio-dev@lists.linuxaudio.org
http://lists.linuxaudio.org/listinfo/linux-audio-dev