[PD] talk to php-website with netsend

IOhannes m zmoelnig zmoelnig at iem.at
Tue Oct 2 10:02:55 CEST 2018

On 10/2/18 2:26 AM, Marco Hugo Schretter wrote:
> hi all,
> is there a way to use netsend to talk to a php based website.
> i'd like to send something corresponding to
> :this works:
> [curl -s
> |
> [shell]
> i'd like to get rid of [shell] (for windows etc) and do e.g.
> :this does not work:
> [connect 80(
> |
> | [send skript.php/?action=play(
> |/
> [netsend]

netsend uses FUDI as the default protocol, which means that the text you
are sending gets a terminating semicolon.
the receiver really sees "skript.php/?action=play;"

however, when you instruct curl to talk to a web-server, you are using
the HTTP protocol, which is much more complex.
it really sends something like:

GET /skript.php/?action=play HTTP/1.1
User-Agent: curl/7.61.0
Accept: */*

with all the lines terminated with CRLF.

depending on your setup (e.g. now virtual-hosts involved), you might get
away with a single CRLF-terminated line:

GET /skript.php/?action=play HTTP/1.1

now netsend has a binary-mode, which allows you to specify the raw bytes
you want to transmit (no more FUDI): [netsend -b]

the only remaining hurdle is to create that list of bytes.
you could use [list fromsymbol] for this, but it only works on symbols
(and not on lists of symbols).
so one way would be to serialize your message "GET /skript.php HTTP/1.1"
into 3 1-symbol messages, convert those to lists of bytes with [list
fromsymbol] and merge those lists into a single one, manually adding the
connecting space (32) and the terminating CRLF (13 10).

an alternative is to use [fudiformat], which converts entire messages
into FUDI bytelists (very similar to [list fromsymbol] for lists; but
appends a terminating ";\n"), then split away the trailing two bytes
(";\n" aka: 59 10) and append CRLF (13 10).

most likely, your server will require an explicit "Host" line, so repeat
the above to get it.

if you are only ever sending the same string to the server, you could of
course just translate the HTTP-requests into bytes once, and store the
bytelist in your patch (which makes it a little harder to debug, unless
you are good at translating decimal values to ascii)


-------------- 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/20181002/9df7f564/attachment.sig>

More information about the Pd-list mailing list