[PD] listing to json port?

IOhannes m zmoelnig zmoelnig at iem.at
Tue Sep 5 11:17:04 CEST 2017

On 09/05/17 02:31, João Pais wrote:
>>> Hello list,
>>> I wanted to know if it's possible to listen to a port 6437, where some
>>> json messages are coming in. I've seen in my webbrowser that the port is
>>> indeed active, but when I try udpreceive nothing comes out - which
>>> probably means that I'm not getting the process.
>> tcpreceive?
> that would probably work, but I guess the javascript code is necessary
> to open the port in the first place. Is there a way of Pd opening a html
> file with that?

i'm not sure i understand the problem.
you write:

> if it's possible to listen to a port 6437

the answer is: yes of course.
there are two things to keep in mind though:
- you must know whether the protocol is TCP/IP or UDP. without that
information, the port is pretty useless.
since this is about JSON and web-technology, chances are high that the
protocol is indeed TCP/IP, that's why is suggested to use [tcpreceive]
instead of [udpreceive].
- on a given machine, you can only have a single listener listening on a
given port. so if you have a webbrowser already monitoring the data, you
can *not* also have Pd doing the same (on the same machine).

in any case, there also might be some confusion about "listening". it
could well be, that you are trying to talk to a webserver that speaks
JSON via a REST API. in which case, your Pd patch wouldn't *listen* but
instead connect to the webserver ([tcpclient]).

in any case, purest-json is a library (available via deken) that
facilitates the interaction with JSON-based REST apis quite a lot.
you probably should have a look at it.

also note that with modern Pd, you can exchange your
[tcpreceive]/[udpreceive] with the builtin [netreceive], which as gotten
a binary mode ("-b") that will output the same format as [tcpreceive].


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <http://lists.puredata.info/pipermail/pd-list/attachments/20170905/f883038f/attachment.sig>

More information about the Pd-list mailing list