aboutsummaryrefslogtreecommitdiff
path: root/net/tcpsocketserver-help.pd
blob: d0e60454d0eea42c1b0cee61275ff1d0fca42cbc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
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;