diff options
author | Roman Haefeli <rdz@users.sourceforge.net> | 2011-02-01 21:52:52 +0000 |
---|---|---|
committer | Roman Haefeli <rdz@users.sourceforge.net> | 2011-02-01 21:52:52 +0000 |
commit | fa47f6ea2ee29607de4d97a79d24b83f0b8c25f9 (patch) | |
tree | 750c0f0e2d47873f61e32eca8fa866861632e897 | |
parent | 8b9217d670d48cd31f7d96dbc2ac6ba0cb93451e (diff) |
those abstractions actually belong to the 'net' section
svn path=/trunk/externals/mrpeach/; revision=14850
-rw-r--r-- | net/tcpsocket.FUDI.pd | 166 | ||||
-rw-r--r-- | net/tcpsocket.OSC.pd | 89 | ||||
-rw-r--r-- | net/tcpsocketserver-help.pd | 301 | ||||
-rw-r--r-- | net/tcpsocketserver.pd | 106 |
4 files changed, 662 insertions, 0 deletions
diff --git a/net/tcpsocket.FUDI.pd b/net/tcpsocket.FUDI.pd new file mode 100644 index 0000000..74194d3 --- /dev/null +++ b/net/tcpsocket.FUDI.pd @@ -0,0 +1,166 @@ +#N canvas 585 75 446 533 10;
+#X obj 50 49 == \$2;
+#X obj 7 28 route in socket;
+#X obj 7 76 spigot;
+#N canvas 622 183 512 335 reset 0;
+#X obj 23 41 route \$2;
+#X obj 23 63 route reset;
+#X obj 23 83 t b b;
+#X msg 55 170 done;
+#X obj 23 113 outlet;
+#X text 161 33 this is used to:;
+#X text 87 114 a) reset the sockethandler on a new connection;
+#X text 88 129 (for instance \, if the previous connection was quitted
+in the middle of a packet).;
+#X text 55 213 b) check for the socketserver \, if a sockethandler
+on specified socket already exists.;
+#X obj 55 191 s \$1.TCPSOCKET;
+#X obj 23 19 r \$1.TCPSOCKET;
+#X connect 0 0 1 0;
+#X connect 1 0 2 0;
+#X connect 2 0 4 0;
+#X connect 2 1 3 0;
+#X connect 3 0 9 0;
+#X connect 10 0 0 0;
+#X restore 46 102 pd reset;
+#X obj 105 279 route socket ip;
+#X obj 41 367 list append;
+#X obj 58 323 list append;
+#X obj 7 299 t a b b b;
+#X obj 7 414 list prepend out;
+#X obj 41 391 list prepend socket.out;
+#X obj 58 345 list prepend ip.out;
+#X obj 7 442 list trim;
+#X text 16 220 the lower part makes [tcpsocketserver] behave like [tcpserver]
+;
+#X obj -2 136 cnv 15 450 70 empty empty empty 20 12 0 14 -204786 -66577
+0;
+#N canvas 385 67 606 479 FUDI 0;
+#X obj 23 6 inlet;
+#X obj 23 400 outlet;
+#N canvas 389 242 191 341 serialize 0;
+#X obj 5 100 t a a;
+#X obj 37 122 list prepend 0;
+#X obj 37 143 s \$0.inbuffer;
+#X obj 5 174 list length;
+#X obj 5 218 until;
+#X obj 5 195 t a b;
+#X obj 5 241 f;
+#X obj 50 244 + 1;
+#X msg 49 218 0;
+#X obj 5 267 tabread \$0.inbuffer;
+#X obj 5 50 inlet;
+#X obj 5 289 outlet;
+#X obj 5 12 table \$0.inbuffer 8192;
+#N canvas 294 258 396 232 list_serialize_raw 0;
+#X obj 13 73 until;
+#X obj 13 97 list append;
+#X obj 13 47 t b a;
+#X obj 13 23 inlet;
+#X obj 13 169 outlet;
+#X obj 13 121 list split 8192;
+#X obj 141 106 b;
+#X text 12 190 cut incoming list into pieces of a maximum of the buffersize.
+;
+#X connect 0 0 1 0;
+#X connect 1 0 5 0;
+#X connect 2 0 0 0;
+#X connect 2 1 1 1;
+#X connect 3 0 2 0;
+#X connect 5 0 4 0;
+#X connect 5 1 1 1;
+#X connect 5 2 6 0;
+#X connect 5 2 4 0;
+#X connect 6 0 0 1;
+#X restore 5 74 pd list_serialize_raw;
+#X connect 0 0 3 0;
+#X connect 0 1 1 0;
+#X connect 1 0 2 0;
+#X connect 3 0 5 0;
+#X connect 4 0 6 0;
+#X connect 5 0 4 0;
+#X connect 5 1 8 0;
+#X connect 6 0 7 0;
+#X connect 6 0 9 0;
+#X connect 7 0 6 1;
+#X connect 8 0 6 1;
+#X connect 9 0 11 0;
+#X connect 10 0 13 0;
+#X connect 13 0 0 0;
+#X restore 23 30 pd serialize;
+#X obj 23 109 t a a;
+#X obj 97 297 list prepend;
+#X obj 195 296 t a;
+#X obj 23 327 list append;
+#X obj 23 350 t a b;
+#X obj 160 56 inlet;
+#X text 210 56 reset;
+#X obj 23 53 sel 10 13;
+#X msg 23 76 32;
+#X obj 23 219 sel 59;
+#X obj 178 264 b;
+#X obj 23 373 list append 10;
+#X obj 23 149 sel 92;
+#X msg 23 171 -1;
+#X obj 62 171 t a a;
+#X msg 62 193 59;
+#X text 119 182 <-;
+#X text 144 176 separate by 59 (semicolon) \, but ignore semicolons
+prepended by 92 (backslash);
+#X connect 0 0 2 0;
+#X connect 2 0 10 0;
+#X connect 3 0 15 0;
+#X connect 3 1 4 0;
+#X connect 4 0 5 0;
+#X connect 4 0 6 1;
+#X connect 5 0 4 1;
+#X connect 6 0 7 0;
+#X connect 7 0 14 0;
+#X connect 7 1 6 1;
+#X connect 7 1 4 1;
+#X connect 8 0 13 0;
+#X connect 10 0 11 0;
+#X connect 10 1 11 0;
+#X connect 10 2 3 0;
+#X connect 11 0 3 0;
+#X connect 12 0 6 0;
+#X connect 13 0 4 1;
+#X connect 13 0 6 1;
+#X connect 14 0 1 0;
+#X connect 15 0 16 0;
+#X connect 15 1 17 0;
+#X connect 16 0 12 1;
+#X connect 17 0 18 0;
+#X connect 17 1 12 0;
+#X connect 18 0 12 1;
+#X restore 7 161 pd FUDI;
+#X text 70 162 <- PUT HERE THE PROTOCOL SPECIFIC DELIMITER CODE;
+#X text 15 197 --------------------------------------------------------
+;
+#X text 12 129 --------------------------------------------------------
+;
+#X obj 7 6 r \$1.TCPSOCKET;
+#X obj 7 465 s \$1.TCPSOCKET;
+#X obj 105 255 r \$1.TCPSOCKET;
+#X text 200 454 Author: Roman Haefeli;
+#X text 50 74 <- only pass stream of own socket;
+#X text 201 474 Version: 2009-02-02;
+#X connect 0 0 2 1;
+#X connect 1 0 2 0;
+#X connect 1 1 0 0;
+#X connect 2 0 14 0;
+#X connect 3 0 14 1;
+#X connect 4 0 5 1;
+#X connect 4 1 6 1;
+#X connect 5 0 9 0;
+#X connect 6 0 10 0;
+#X connect 7 0 8 0;
+#X connect 7 2 5 0;
+#X connect 7 3 6 0;
+#X connect 8 0 11 0;
+#X connect 9 0 11 0;
+#X connect 10 0 11 0;
+#X connect 11 0 19 0;
+#X connect 14 0 7 0;
+#X connect 18 0 1 0;
+#X connect 20 0 4 0;
diff --git a/net/tcpsocket.OSC.pd b/net/tcpsocket.OSC.pd new file mode 100644 index 0000000..f3e47da --- /dev/null +++ b/net/tcpsocket.OSC.pd @@ -0,0 +1,89 @@ +#N canvas 636 71 455 534 10; +#X obj 50 49 == \$2; +#X obj 7 28 route in socket; +#X obj 7 76 spigot; +#N canvas 622 183 512 335 reset 0; +#X obj 23 41 route \$2; +#X obj 23 63 route reset; +#X obj 23 83 t b b; +#X msg 55 170 done; +#X obj 23 113 outlet; +#X text 161 33 this is used to:; +#X text 87 114 a) reset the sockethandler on a new connection; +#X text 88 129 (for instance \, if the previous connection was quitted +in the middle of a packet).; +#X text 55 213 b) check for the socketserver \, if a sockethandler +on specified socket already exists.; +#X obj 55 191 s \$1.TCPSOCKET; +#X obj 23 19 r \$1.TCPSOCKET; +#X connect 0 0 1 0; +#X connect 1 0 2 0; +#X connect 2 0 4 0; +#X connect 2 1 3 0; +#X connect 3 0 9 0; +#X connect 10 0 0 0; +#X restore 40 102 pd reset; +#X obj 104 280 route socket ip; +#X obj 41 367 list append; +#X obj 58 323 list append; +#X obj 7 299 t a b b b; +#X obj 7 414 list prepend out; +#X obj 41 391 list prepend socket.out; +#X obj 58 345 list prepend ip.out; +#X obj 7 442 list trim; +#X text 16 220 the lower part makes [tcpsocketserver] behave like [tcpserver] +; +#X obj -2 136 cnv 15 450 70 empty empty empty 20 12 0 14 -204786 -66577 +0; +#X text 70 162 <- PUT HERE THE PROTOCOL SPECIFIC DELIMITER CODE; +#X text 15 197 -------------------------------------------------------- +; +#X text 13 129 -------------------------------------------------------- +; +#X obj 7 6 r \$1.TCPSOCKET; +#X obj 7 465 s \$1.TCPSOCKET; +#X obj 104 256 r \$1.TCPSOCKET; +#X text 200 454 Author: Roman Haefeli; +#X text 55 75 <- only pass stream of own socket; +#N canvas 389 116 266 236 OSC 0; +#X obj 27 18 inlet; +#X obj 27 186 outlet; +#X obj 144 23 inlet; +#X text 194 23 reset; +#X obj 27 123 mrpeach/slipdec 16384; +#X obj 27 151 spigot 1; +#X obj 144 45 t b b b; +#X msg 163 67 192 192; +#X msg 183 99 0; +#X msg 144 100 1; +#X connect 0 0 4 0; +#X connect 2 0 6 0; +#X connect 4 0 5 0; +#X connect 5 0 1 0; +#X connect 6 0 9 0; +#X connect 6 1 7 0; +#X connect 6 2 8 0; +#X connect 7 0 4 0; +#X connect 8 0 5 1; +#X connect 9 0 5 1; +#X restore 7 161 pd OSC; +#X text 201 474 Version: 2011-01-05; +#X connect 0 0 2 1; +#X connect 1 0 2 0; +#X connect 1 1 0 0; +#X connect 2 0 22 0; +#X connect 3 0 22 1; +#X connect 4 0 5 1; +#X connect 4 1 6 1; +#X connect 5 0 9 0; +#X connect 6 0 10 0; +#X connect 7 0 8 0; +#X connect 7 2 5 0; +#X connect 7 3 6 0; +#X connect 8 0 11 0; +#X connect 9 0 11 0; +#X connect 10 0 11 0; +#X connect 11 0 18 0; +#X connect 17 0 1 0; +#X connect 19 0 4 0; +#X connect 22 0 7 0; diff --git a/net/tcpsocketserver-help.pd b/net/tcpsocketserver-help.pd new file mode 100644 index 0000000..d0e6045 --- /dev/null +++ b/net/tcpsocketserver-help.pd @@ -0,0 +1,301 @@ +#N canvas 35 3 878 523 10;
+#X declare -stdpath extra/mrpeach;
+#X declare -stdlib extra/pdstring declare -stdlib extra/maxlib;
+#X declare -stdpath extra/mrpeach;
+#X declare -stdlib extra/pdstring declare -stdlib extra/maxlib;
+#X declare -stdpath extra/mrpeach;
+#X msg 471 74 print;
+#X text 521 75 list of connections;
+#X text 627 103 send to all clients;
+#X text 629 132 send to client 1;
+#X text 615 155 send to client on socket 504;
+#X text 613 28 'send' prefix is optional;
+#X text 474 48 (the first number is socket number);
+#X msg 556 257 disconnectsocket \$1;
+#X msg 484 284 disconnectclient \$1;
+#X floatatom 506 215 5 0 0 0 - - -;
+#X obj 484 235 f;
+#X obj 484 216 bng 15 250 50 0 empty empty empty 17 7 0 10 -258699
+-241291 -1;
+#X floatatom 578 216 5 0 0 0 - - -;
+#X obj 556 235 f;
+#X obj 556 216 bng 15 250 50 0 empty empty empty 17 7 0 10 -258699
+-241291 -1;
+#X text 483 197 disconnect by socket or client number;
+#X obj 618 335 unpack 0 0 0 0;
+#X floatatom 618 355 3 0 0 0 - - -;
+#X floatatom 649 355 3 0 0 0 - - -;
+#X floatatom 681 356 3 0 0 0 - - -;
+#X floatatom 715 356 3 0 0 0 - - -;
+#X text 616 372 IP;
+#X floatatom 569 355 5 0 0 0 - - -;
+#X text 566 371 socket;
+#X floatatom 520 376 5 0 0 0 - - -;
+#X text 520 391 number of connections;
+#X obj 471 433 spigot;
+#X obj 510 413 tgl 15 0 empty empty enable_print 17 7 0 10 -24198 -258699
+-258699 0 1;
+#X text 15 37 [tcpsocketserver <protocol> <port>];
+#X obj 469 311 cnv 15 185 22 empty empty empty 20 12 0 14 -204786 -66577
+0;
+#X obj 471 314 tcpsocketserver FUDI 2468;
+#X text 15 115 [tcpsocketserver] is able to handle multiple sockets
+of a packet oriented protocol correctly \, unlike [tcpserver] \, which
+might mix up packets from different sockets.;
+#X text 24 308 - OSC;
+#X text 16 245 each protocol requires its own specific socket handler
+abstraction \, which should be named [tcpsocket.PROTOCOL]. currently
+available are the protocols:;
+#X text 23 293 - FUDI;
+#N canvas 704 167 472 356 EXTENDABILITY 0;
+#X text 3 39 Support for more protocols can easily be added. In order
+to do so:;
+#X text 5 10 EXTENDABILITY;
+#X text 6 105 - open tcpsocket.NEWPROTOCOL.pd;
+#X text 7 127 - edit the green-marked subpatch;
+#X text 10 208 - save it;
+#X text 12 227 - in order to use it \, instantiate:;
+#X text 46 247 [tcpsocketserver NEWPROTOCOL <port>];
+#X text 8 148 - replace code with code \, that creates proper packets
+out of the incoming stream for the desired protocol. don't forget to
+implement a reset mechanism \, in case a socket is closed in the middle
+of packet transmission.;
+#X text 5 83 - copy tcpsocket.FUDI.pd to tcpsocket.NEWPROTOCOL.pd;
+#X restore 21 387 pd EXTENDABILITY;
+#X text 17 453 Author: Roman Haefeli;
+#X text 16 468 Version: 2009-01-11;
+#X text 15 65 [tcpsocketserver] is meant to be a protocol-aware drop-in
+replacement for [tcpserver]. it uses same the same inlet and outlet
+configuration as [tcpserver].;
+#X text 469 478 only well-formed FUDI messages are received here.;
+#N canvas 469 232 147 274 EXAMPLES 0;
+#N canvas 231 0 579 756 FUDI 0;
+#X obj 9 39 cnv 15 550 240 empty empty client_1 20 12 0 14 -249661
+-66577 0;
+#X obj 25 193 tcpclient;
+#X msg 369 94 connect localhost 11001;
+#X msg 393 115 disconnect;
+#X obj 369 72 sel 1 0;
+#X obj 369 51 tgl 15 0 empty empty empty 17 7 0 10 -261234 -1 -1 0
+1;
+#X obj 25 259 print CLIENT_1;
+#X msg 25 70 one two;
+#X obj 25 91 any2string 0 -1;
+#X msg 69 151 59 10;
+#X msg 33 117 32 116 104 114 101 101 23;
+#X obj 9 286 cnv 15 550 150 empty empty client_2 20 12 0 14 -249661
+-66577 0;
+#X msg 369 341 connect localhost 11001;
+#X msg 393 362 disconnect;
+#X obj 369 319 sel 1 0;
+#X obj 369 298 tgl 15 0 empty empty empty 17 7 0 10 -261234 -1 -1 0
+1;
+#X obj 25 214 string2any 0 59;
+#X obj 25 234 route bang;
+#X obj 25 373 netclient;
+#X obj 8 9 declare -stdlib extra/pdstring declare -stdlib extra/maxlib
+;
+#X obj 25 402 print CLIENT_2;
+#X text 169 324 <- send FUDI message;
+#X obj 10 444 cnv 15 550 300 empty empty FUDI_server 20 12 0 14 -241408
+-66577 0;
+#X obj 12 600 tcpsocketserver FUDI 11001;
+#X obj 12 674 string2any 0 59;
+#X obj 12 695 route bang;
+#X obj 191 620 unpack 0 0 0 0;
+#X floatatom 191 640 3 0 0 0 - - -;
+#X floatatom 222 640 3 0 0 0 - - -;
+#X floatatom 254 641 3 0 0 0 - - -;
+#X floatatom 288 641 3 0 0 0 - - -;
+#X text 189 657 IP;
+#X floatatom 131 640 5 0 0 0 - - -;
+#X floatatom 71 641 5 0 0 0 - - -;
+#X text 60 656 clients;
+#X text 127 656 socket;
+#X text 132 675 <--;
+#X text 165 675 [tcpsocketserver FUDI] does _not_ remove the trailing
+' \; ';
+#X text 165 70 1) start a FUDI message;
+#X text 232 118 2) continue;
+#X text 118 152 3) finish FUDI message (with semicolon - newline);
+#X text 391 52 connect;
+#X text 390 296 connect;
+#X text 20 475 [tcpsocketserver FUDI] doesn't take care of building
+FUDI-compliant messages. this should be done by the user.;
+#X text 154 216 4) try sending a message from client_2 during composing
+a message with client_1 and see \, how the server behaves.;
+#X text 279 522 <- this doesn't work;
+#X text 315 549 <- this should;
+#X msg 25 323 send four five six;
+#X msg 43 550 client 2 115 101 118 101 110 32 59 10;
+#X msg 42 521 client 2 115 101 118 101 110 32;
+#X obj 12 720 print SERVER;
+#X connect 1 0 16 0;
+#X connect 2 0 1 0;
+#X connect 3 0 1 0;
+#X connect 4 0 2 0;
+#X connect 4 1 3 0;
+#X connect 5 0 4 0;
+#X connect 7 0 8 0;
+#X connect 8 0 1 0;
+#X connect 9 0 1 0;
+#X connect 10 0 1 0;
+#X connect 12 0 18 0;
+#X connect 13 0 18 0;
+#X connect 14 0 12 0;
+#X connect 14 1 13 0;
+#X connect 15 0 14 0;
+#X connect 16 0 17 0;
+#X connect 17 1 6 0;
+#X connect 18 0 20 0;
+#X connect 23 0 24 0;
+#X connect 23 1 33 0;
+#X connect 23 2 32 0;
+#X connect 23 3 26 0;
+#X connect 24 0 25 0;
+#X connect 25 1 50 0;
+#X connect 26 0 27 0;
+#X connect 26 1 28 0;
+#X connect 26 2 29 0;
+#X connect 26 3 30 0;
+#X connect 47 0 18 0;
+#X connect 48 0 23 0;
+#X connect 49 0 23 0;
+#X restore 23 25 pd FUDI;
+#N canvas 231 0 579 756 OSC 0;
+#X obj 9 39 cnv 15 550 240 empty empty client_1 20 12 0 14 -249661
+-66577 0;
+#X obj 25 211 tcpclient;
+#X msg 357 229 disconnect;
+#X obj 333 186 sel 1 0;
+#X obj 333 165 tgl 15 0 empty empty empty 17 7 0 10 -261234 -1 -1 0
+1;
+#X obj 25 259 print CLIENT_1;
+#X obj 9 286 cnv 15 550 150 empty empty client_2 20 12 0 14 -249661
+-66577 0;
+#X msg 393 362 disconnect;
+#X obj 369 319 sel 1 0;
+#X obj 369 298 tgl 15 0 empty empty empty 17 7 0 10 -261234 -1 -1 0
+1;
+#X obj 8 9 declare -stdlib extra/pdstring declare -stdlib extra/maxlib
+;
+#X obj 25 417 print CLIENT_2;
+#X obj 10 444 cnv 15 550 300 empty empty OSC_server 20 12 0 14 -241408
+-66577 0;
+#X obj 188 636 unpack 0 0 0 0;
+#X floatatom 188 656 3 0 0 0 - - -;
+#X floatatom 219 656 3 0 0 0 - - -;
+#X floatatom 251 657 3 0 0 0 - - -;
+#X floatatom 285 657 3 0 0 0 - - -;
+#X text 186 673 IP;
+#X floatatom 130 656 5 0 0 0 - - -;
+#X floatatom 73 657 5 0 0 0 - - -;
+#X text 62 672 clients;
+#X text 126 672 socket;
+#X text 355 166 connect;
+#X text 390 296 connect;
+#X obj 16 616 tcpsocketserver OSC 11002;
+#X obj 16 694 unpackOSC;
+#X obj 16 720 print SERVER;
+#X msg 333 208 connect localhost 11002;
+#X msg 369 341 connect localhost 11002;
+#X obj 25 234 unpackOSCstream;
+#X obj 25 373 tcpclient;
+#X obj 25 395 unpackOSCstream;
+#X msg 49 498 /synth1/tone3/freq 440;
+#X msg 25 79 0 0 0 16 47 102 114 101 113;
+#X msg 41 104 0 0 0 44 105 0 0 0 0 1 184;
+#X text 155 324 send OSC message;
+#X msg 25 323 /amplitude 0.78;
+#X obj 25 347 packOSCstream;
+#X obj 16 522 packOSCstream;
+#X obj 16 594 list trim;
+#X msg 16 473 /synth3/tone4/amplitude 0.36;
+#X obj 180 555 hradio 15 1 0 2 empty empty empty 0 -8 0 10 -4034 -1
+-1 0;
+#X obj 180 573 + 1;
+#X text 221 555 client;
+#X obj 16 551 list prepend 1;
+#X obj 16 573 list prepend client;
+#X text 236 80 1) start sending an OSC packet;
+#X text 247 106 2) complete the OSC packet;
+#X text 59 137 also try sending an OSC packet from client_2 between
+1) and 2);
+#X text 124 520 <- use [packOSCstream] in order to create OSC packets
+suitable for tcp transport.;
+#X text 238 486 send to clients;
+#X text 93 695 <---;
+#X text 139 694 CAUTION: not [unpackOSCstream] is used here \, since
+[tcpsocket.OSC] already removes the 4-byte header.;
+#X connect 1 0 30 0;
+#X connect 2 0 1 0;
+#X connect 3 0 28 0;
+#X connect 3 1 2 0;
+#X connect 4 0 3 0;
+#X connect 7 0 31 0;
+#X connect 8 0 29 0;
+#X connect 8 1 7 0;
+#X connect 9 0 8 0;
+#X connect 13 0 14 0;
+#X connect 13 1 15 0;
+#X connect 13 2 16 0;
+#X connect 13 3 17 0;
+#X connect 25 0 26 0;
+#X connect 25 1 20 0;
+#X connect 25 2 19 0;
+#X connect 25 3 13 0;
+#X connect 26 0 27 0;
+#X connect 28 0 1 0;
+#X connect 29 0 31 0;
+#X connect 30 0 5 0;
+#X connect 31 0 32 0;
+#X connect 32 0 11 0;
+#X connect 33 0 39 0;
+#X connect 34 0 1 0;
+#X connect 35 0 1 0;
+#X connect 37 0 38 0;
+#X connect 38 0 31 0;
+#X connect 39 0 45 0;
+#X connect 40 0 25 0;
+#X connect 41 0 39 0;
+#X connect 42 0 43 0;
+#X connect 43 0 45 1;
+#X connect 45 0 46 0;
+#X connect 46 0 40 0;
+#X restore 23 49 pd OSC;
+#X restore 21 365 pd EXAMPLES;
+#X obj 471 455 print FUDI;
+#X msg 471 101 broadcast 97 98 99 59 10;
+#X msg 471 128 client 1 97 98 99 59 10;
+#X msg 471 155 send 504 97 98 99 59 10;
+#X msg 471 28 10 97 98 99 59 10;
+#X text 17 8 TCPSOCKETSERVER - a protocol-aware wrapper aroun [tcpserver]
+;
+#X text 13 167 [tcpsocketserver] dynamically creates (internally) an
+instance of a socket handler abstraction [tcpsocket.PROTOCOL] for each
+opened socket. every socket handler creates proper packets from the
+incoming stream and sends them to the left outlet of [tcpsocketserver].
+;
+#X connect 0 0 30 0;
+#X connect 7 0 30 0;
+#X connect 8 0 30 0;
+#X connect 9 0 10 1;
+#X connect 10 0 8 0;
+#X connect 11 0 10 0;
+#X connect 12 0 13 1;
+#X connect 13 0 7 0;
+#X connect 14 0 13 0;
+#X connect 16 0 17 0;
+#X connect 16 1 18 0;
+#X connect 16 2 19 0;
+#X connect 16 3 20 0;
+#X connect 26 0 41 0;
+#X connect 27 0 26 1;
+#X connect 30 0 26 0;
+#X connect 30 1 24 0;
+#X connect 30 2 22 0;
+#X connect 30 3 16 0;
+#X connect 42 0 30 0;
+#X connect 43 0 30 0;
+#X connect 44 0 30 0;
+#X connect 45 0 30 0;
diff --git a/net/tcpsocketserver.pd b/net/tcpsocketserver.pd new file mode 100644 index 0000000..3e8f8dd --- /dev/null +++ b/net/tcpsocketserver.pd @@ -0,0 +1,106 @@ +#N canvas 332 12 333 552 10;
+#X declare -stdpath extra/mrpeach;
+#X obj 13 39 inlet;
+#X obj 13 464 outlet;
+#X obj 75 463 outlet;
+#X obj 137 463 outlet;
+#X obj 199 462 outlet;
+#X obj 36 187 list trim;
+#X obj 59 145 list trim;
+#X obj 59 124 list prepend socket;
+#X obj 36 166 list prepend num_of_clients;
+#X obj 82 103 list trim;
+#X obj 82 82 list prepend ip;
+#N canvas 816 227 247 348 \$0.TCPSOCKETCONTAINER 0;
+#X restore 14 372 pd \$0.TCPSOCKETCONTAINER;
+#N canvas 491 218 502 504 socketmanager 0;
+#X msg 24 196 \$1 reset;
+#X obj 25 259 route done;
+#X obj 5 175 t a a b;
+#X msg 25 280 0;
+#X msg 44 280 1;
+#X obj 5 303 spigot;
+#X obj 44 344 f;
+#X obj 76 344 + 20;
+#X obj 5 323 t a b b;
+#X obj 24 365 list append \$1;
+#X obj 24 388 list append;
+#X obj 5 412 list append;
+#X obj 5 476 s pd-\$0.TCPSOCKETCONTAINER;
+#X obj 5 432 list append \$0;
+#X obj 5 24 route socket num_of_clients;
+#X obj 84 46 t a a;
+#X obj 69 73 -;
+#X obj 69 94 == 1;
+#X obj 5 122 spigot;
+#X obj 5 3 r \$0.TCPSOCKET;
+#X obj 24 217 s \$0.TCPSOCKET;
+#X obj 25 238 r \$0.TCPSOCKET;
+#X msg 5 454 obj 10 \$3 tcpsocket.\$2 \$4 \$1 \, loadbang;
+#X obj 5 148 t a b;
+#X msg 65 132 0;
+#X text 116 78 when a new client connects (num_of_clients: +1);
+#X text 119 197 send a 'reset' to the according socket handler;
+#X text 114 266 and if it doesn't respond (which means \, there is
+no socket handler on specified socket) \,;
+#X text 119 368 create one (into pd-\$0.TCPSOCKETCONTAINER).;
+#X connect 0 0 20 0;
+#X connect 1 0 3 0;
+#X connect 2 0 5 0;
+#X connect 2 1 0 0;
+#X connect 2 2 4 0;
+#X connect 3 0 5 1;
+#X connect 4 0 5 1;
+#X connect 5 0 8 0;
+#X connect 6 0 7 0;
+#X connect 6 0 10 1;
+#X connect 7 0 6 1;
+#X connect 8 0 11 0;
+#X connect 8 1 9 0;
+#X connect 8 2 6 0;
+#X connect 9 0 10 0;
+#X connect 10 0 11 1;
+#X connect 11 0 13 0;
+#X connect 13 0 22 0;
+#X connect 14 0 18 0;
+#X connect 14 1 15 0;
+#X connect 15 0 16 1;
+#X connect 15 1 16 0;
+#X connect 16 0 17 0;
+#X connect 17 0 18 1;
+#X connect 18 0 23 0;
+#X connect 19 0 14 0;
+#X connect 21 0 1 0;
+#X connect 22 0 12 0;
+#X connect 23 0 2 0;
+#X connect 23 1 24 0;
+#X connect 24 0 18 1;
+#X restore 14 349 pd socketmanager;
+#X obj 13 60 tcpserver \$2;
+#X obj 13 417 r \$0.TCPSOCKET;
+#X obj 13 208 list prepend in;
+#X obj 13 440 route out num_of_clients socket.out ip.out;
+#X obj 13 230 list trim;
+#X obj 82 316 s \$0.TCPSOCKET;
+#X text 23 501 Author: Roman Haefeli;
+#X text 24 518 Version: 2009-01-11;
+#X text 94 292 [tcpsocketserver <protocol> <port>];
+#X obj 13 14 declare -stdpath extra/mrpeach;
+#X connect 0 0 13 0;
+#X connect 5 0 18 0;
+#X connect 6 0 18 0;
+#X connect 7 0 6 0;
+#X connect 8 0 5 0;
+#X connect 9 0 18 0;
+#X connect 10 0 9 0;
+#X connect 13 0 15 0;
+#X connect 13 1 8 0;
+#X connect 13 2 7 0;
+#X connect 13 3 10 0;
+#X connect 14 0 16 0;
+#X connect 15 0 17 0;
+#X connect 16 0 1 0;
+#X connect 16 1 2 0;
+#X connect 16 2 3 0;
+#X connect 16 3 4 0;
+#X connect 17 0 18 0;
|