This reminds me of the funny limitation that in PD a client can only send ([netsend]) and a server can only receive ([netreceive]).
Wouldn't it be great to have a [netclient] object, almost identical to [netsend] but capable of receiving as well as sending messages (an outlet for received messages just like netreceive), and a [netserver], almost identical to [netreceive] but capable of sending as well as receiving messages (an inlet with methods identical to those of netsend)?
Maybe there's already something like this in Extended, but wouldn't it deserve being included in Vanilla?
Matteo Sisti Sette wrote:
This reminds me of the funny limitation that in PD a client can only send ([netsend]) and a server can only receive ([netreceive]).
Wouldn't it be great to have a [netclient] object, almost identical to [netsend] but capable of receiving as well as sending messages (an outlet for received messages just like netreceive), and a [netserver], almost identical to [netreceive] but capable of sending as well as receiving messages (an inlet with methods identical to those of netsend)?
Maybe there's already something like this in Extended, but wouldn't it deserve being included in Vanilla?
sockets are one way, you can do the same thing every other app does, and open two streams in each side: one sending, the other receiving. This can be done with the existing objects.
refer here for more info http://beej.us/guide/bgnet/
Justin Glenn Smith wrote:
Matteo Sisti Sette wrote:
This reminds me of the funny limitation that in PD a client can only send ([netsend]) and a server can only receive ([netreceive]).
Wouldn't it be great to have a [netclient] object, almost identical to [netsend] but capable of receiving as well as sending messages (an outlet for received messages just like netreceive), and a [netserver], almost identical to [netreceive] but capable of sending as well as receiving messages (an inlet with methods identical to those of netsend)?
Maybe there's already something like this in Extended, but wouldn't it deserve being included in Vanilla?
sockets are one way, you can do the same thing every other app does, and open two streams in each side: one sending, the other receiving. This can be done with the existing objects.
refer here for more info http://beej.us/guide/bgnet/
never mind, I was confused there, a normal socket does allow both send and receive.
For PD to have two-way sockets, and have them be really useful, we would have to have dynamically created connections, and this kind of thing is a little trickier in PD than it is in a textual programming language.
Justin Glenn Smith escribió:
never mind, I was confused there, a normal socket does allow both send and receive.
For PD to have two-way sockets, and have them be really useful, we would have to have dynamically created connections, and this kind of thing is a little trickier in PD than it is in a textual programming language.
I'm not sure I understand. Connection are already dynamically created: [netsend] connects to a server by sending it a "connect" message.
I don't dubt it is complicated to implement the sort of communication PD does, but given what is already implemented, I don't see the "extra" complication of implementing a scenario similar to the one I described.
And from the standpoint of the user (or patcher), I think it would be pretty flexible and quite simple, i.e. you wouldn't need to worry about the tricky socket complications much more than you need do now.....
All the semantics are already there: [netsend] behaves as a client and already have the connect and disconnect functionalities; it would only need an outlet from which it would output messages it receives from the server (once it has connected). [netreceive] behaves as a server: it would only need an inlet and a "send" method that would behave exactly as the one of [netsend] (but would send to the client, provided.........
Oh! Here's the part I had overlooked! The fact that the current [netreceive] (which is a server) only receives, means that having more than one clients connected to it isn't an "issue" because you don't have to address them. Being able to send through a server socket would imply either: A) somewhat identifying and addressing the connected clients when sending to them (e.g. a "send" message should have an argument somehow identifying the client to send to), or B) just sending to all the clients currently connected.
B would mean reduced functionality compared to a "full featured" server socket, but already something more than the current only-receive server (netreceive). In the case of only one connected client (a pretty common case I guess) it would provide easy bidirectional communication.
A serious (A) solution would be indeed complicated, but not impossible to devise. For example, the [would-be-server]'s outlet that currently only outputs the number of connected clients, could output a message every time an incoming connection is established, and such a message would include the IP address of the client, the TCP port (not of much use presumably), and a unique ID, unique to the _connection_ (call it session if you want). Then the "send" message for the [would-be-server] object would be "send _id_ ..." (where ... is the message to be sent).
With this information, you would be able to recognize the client by its IP address if you need to.....
Just an idea.
m.
On Tue, 2010-02-23 at 21:04 +0100, Matteo Sisti Sette wrote:
Wouldn't it be great to have a [netclient] object, almost identical to [netsend] but capable of receiving as well as sending messages (an outlet for received messages just like netreceive), and a [netserver], almost identical to [netreceive] but capable of sending as well as receiving messages (an inlet with methods identical to those of netsend)?
Maybe there's already something like this in Extended,
Yup. Check out:
[maxlib/netserver] [maxlib/netclient] for speaking FUDI and
[mrpeach/tcpserver] [mrpeach/tcpclient] for speaking plain TCP
Roman
On Tue, Feb 23, 2010 at 09:04:47PM +0100, Matteo Sisti Sette wrote:
Wouldn't it be great to have a [netclient] object, almost identical to
[netsend] but capable of receiving as well as sending messages (an
outlet for received messages just like netreceive),
Hell yes! If Miller included this in Vanilla, I hereby pledge one bottle of top-shelf rum and/or whisky (at his option) to be posted to his offices. Good old bribery.
Incidentally, this library I wrote hacks around the problem by connecting back to patches after they have made a connection to the server. Unfortunately it only works if both machines/devices running Pd are on the same local network. The server is written in Python:
http://mccormick.cx/projects/PdLANParty/
There's also this technique for allowing patches to communicate over HTTP but it requires an OS that can run shellscripts, pdsend, pdreceive in the background:
http://code.google.com/p/pd-http/
Chris.