1comm(n)                      Remote communication                      comm(n)
2
3
4
5______________________________________________________________________________
6

NAME

8       comm - A remote communication facility for Tcl (8.3 and later)
9

SYNOPSIS

11       package require Tcl  8.3
12
13       package require comm  ?4.5.7?
14
15       ::comm::comm send ?-async? ?-command callback? id cmd ?arg arg ...?
16
17       ::comm::comm self
18
19       ::comm::comm interps
20
21       ::comm::comm connect ?id?
22
23       ::comm::comm new chan ?name value ...?
24
25       ::comm::comm channels
26
27       ::comm::comm config
28
29       ::comm::comm config name
30
31       ::comm::comm config ?name value ...?
32
33       ::comm::comm shutdown id
34
35       ::comm::comm abort
36
37       ::comm::comm destroy
38
39       ::comm::comm hook event ?+? ?script?
40
41       ::comm::comm remoteid
42
43       ::comm::comm_send
44
45       ::comm::comm return_async
46
47       $future return ?-code code? ?value?
48
49       $future configure ?-command ?cmdprefix??
50
51       $future cget -command
52
53_________________________________________________________________
54

DESCRIPTION

56       The  comm command provides an inter-interpreter remote execution facil‐
57       ity much like Tk's send(n), except that it uses sockets rather than the
58       X server for the communication path.  As a result, comm works with mul‐
59       tiple interpreters, works on Windows and Macintosh  systems,  and  pro‐
60       vides control over the remote execution path.
61
62       These commands work just like send and winfo interps :
63
64           ::comm::comm send ?-async? id cmd ?arg arg ...?
65           ::comm::comm interps
66
67
68       This is all that is really needed to know in order to use comm
69
70   COMMANDS
71       The package initializes ::comm::comm as the default chan.
72
73       comm  names  communication endpoints with an id unique to each machine.
74       Before sending commands, the  id  of  another  interpreter  is  needed.
75       Unlike  Tk's  send,  comm  doesn't  implicitly know the id's of all the
76       interpreters on the system.  The following four  methods  make  up  the
77       basic comm interface.
78
79       ::comm::comm send ?-async? ?-command callback? id cmd ?arg arg ...?
80              This  invokes  the given command in the interpreter named by id.
81              The command waits for the result and remote errors are  returned
82              unless  the  -async  or  -command option is given.  If -async is
83              given, send returns immediately and there is no further  notifi‐
84              cation  of  result.   If  -command is used, callback specifies a
85              command to invoke when the result is  received.   These  options
86              are  mutually exclusive.  The callback will receive arguments in
87              the form -option value, suitable for  array  set.   The  options
88              are:  -id, the comm id of the interpreter that received the com‐
89              mand; -serial, a unique serial for each command sent to  a  par‐
90              ticular  comm  interpreter; -chan, the comm channel name; -code,
91              the result code of the command; -errorcode,  the  errorcode,  if
92              any,  of  the command; -errorinfo, the errorinfo, if any, of the
93              command; and -result, the return value of the command.  If  con‐
94              nection is lost before a reply is received, the callback will be
95              invoked with a connection lost message with -code equal  to  -1.
96              When -command is used, the command returns the unique serial for
97              the command.
98
99       ::comm::comm self
100              Returns the id for this channel.
101
102       ::comm::comm interps
103              Returns a list of all the remote id's to which this  channel  is
104              connected.   comm learns a new remote id when a command is first
105              issued it, or when a remote id first issues a  command  to  this
106              comm channel.  ::comm::comm ids is an alias for this method.
107
108       ::comm::comm connect ?id?
109              Whereas  ::comm::comm  send  will  automatically  connect to the
110              given id, this forces a connection to a remote id without  send‐
111              ing  a  command.   After  this,  the  remote  id  will appear in
112              ::comm::comm interps.
113
114   EVAL SEMANTICS
115       The evaluation semantics of ::comm::comm send  are  intended  to  match
116       Tk's  send  exactly.  This  means  that comm evaluates arguments on the
117       remote side.
118
119       If you find that ::comm::comm send doesn't work for a  particular  com‐
120       mand,  try  the same thing with Tk's send and see if the result is dif‐
121       ferent.  If there is a problem, please report it.  For instance,  there
122       was  had one report that this command produced an error.  Note that the
123       equivalent send command also produces the same error.
124
125           % ::comm::comm send id llength {a b c}
126           wrong # args: should be "llength list"
127           % send name llength {a b c}
128           wrong # args: should be "llength list"
129
130
131       The eval hook (described below) can be used to change from send's  dou‐
132       ble eval semantics to single eval semantics.
133
134   MULTIPLE CHANNELS
135       More  than  one  comm  channel (or listener) can be created in each Tcl
136       interpreter.  This allows flexibility to  create  full  and  restricted
137       channels.   For instance, hook scripts are specific to the channel they
138       are defined against.
139
140       ::comm::comm new chan ?name value ...?
141              This creates a new channel and Tcl command with the given  chan‐
142              nel  name.   This new command controls the new channel and takes
143              all the same arguments as ::comm::comm.  Any remaining arguments
144              are  passed  to  the config method.  The fully qualified channel
145              name is returned.
146
147       ::comm::comm channels
148              This lists all the channels allocated in this Tcl interpreter.
149
150       The default configuration parameters for a new channel are:
151
152           "-port 0 -local 1 -listen 0 -silent 0"
153
154
155       The default channel ::comm::comm is created with:
156
157           "::comm::comm new ::comm::comm -port 0 -local 1 -listen 1 -silent 0"
158
159
160   CHANNEL CONFIGURATION
161       The config method acts similar to fconfigure in that it sets or queries
162       configuration variables associated with a channel.
163
164       ::comm::comm config
165
166       ::comm::comm config name
167
168       ::comm::comm config ?name value ...?
169              When  given no arguments, config returns a list of all variables
170              and their value With one argument, config returns the  value  of
171              just that argument.  With an even number of arguments, the given
172              variables are set to the given values.
173
174       These configuration variables can be changed (descriptions of them  are
175       elsewhere in this manual page):
176
177       -listen ?0|1?
178
179       -local  ?0|1?
180
181       -port   ?port?
182
183       -silent ?0|1?
184
185       -interp ?interpreter?
186
187       -events ?eventlist?
188
189       These configuration variables are read only:
190
191       -chan    chan
192
193       -serial  n
194
195       -socket  sockIn
196
197       When  config  changes  the  parameters of an existing channel (with the
198       exception of -interp and -events), it closes and reopens the  listening
199       socket.   An  automatically  assigned  channel id will change when this
200       happens.  Recycling the socket is done by invoking ::comm::comm  abort,
201       which causes all active sends to terminate.
202
203   ID/PORT ASSIGNMENTS
204       comm  uses  a  TCP  port  for endpoint id.  The interps (or ids) method
205       merely lists all the TCP ports to which the channel is  connected.   By
206       default, each channel's id is randomly assigned by the operating system
207       (but usually starts at a low value around 1024 and increases each  time
208       a  new  socket is opened).  This behavior is accomplished by giving the
209       -port config option a value of 0.  Alternately,  a  specific  TCP  port
210       number  may  be  provided for a given channel.  As a special case, comm
211       contains code to allocate a a high-numbered TCP port (>10000) by  using
212       -port  {}.  Note that a channel won't be created and initialized unless
213       the specific port can be allocated.
214
215       As a special case, if the channel is configured with -listen 0, then it
216       will  not create a listening socket and will use an id of 0 for itself.
217       Such a channel is only good for outgoing connections (although  once  a
218       connection  is  established,  it  can carry send traffic in both direc‐
219       tions).  As another special case, if the  channel  is  configured  with
220       -silent  0,  then  the  listening  side will ignore connection attempts
221       where the protocol negotiation phase failed,  instead  of  throwing  an
222       error.
223
224   EXECUTION ENVIRONMENT
225       A  communication channel in its default configuration will use the cur‐
226       rent interpreter for the execution of all received scripts, and of  the
227       event scripts associated with the various hooks.
228
229       This  insecure  setup  can  be  changed by the user via the two options
230       -interp, and -events.
231
232       When -interp is set all received scripts  are  executed  in  the  slave
233       interpreter  specified  as the value of the option. This interpreter is
234       expected to exist before configuration. I.e. it is  the  responsibility
235       of  the  user to create it. However afterward the communication channel
236       takes ownership of this interpreter, and will destroy it when the  com‐
237       munication channel is destroyed.  Note that reconfiguration of the com‐
238       munication channel to either  a  different  interpreter  or  the  empty
239       string  will  release  the  ownership without destroying the previously
240       configured interpreter.  The empty string has  a  special  meaning,  it
241       restores  the  default  behaviour  of executing received scripts in the
242       current interpreter.
243
244       Also of note is that replies and callbacks (a special  form  of  reply)
245       are  not  considered as received scripts. They are trusted, part of the
246       internal machinery of comm, and therefore always executed in  the  cur‐
247       rent interpreter.
248
249       Even if an interpreter has been configured as the execution environment
250       for received scripts the event  scripts  associated  with  the  various
251       hooks  will by default still be executed in the current interpreter. To
252       change this use the option -events to declare  a  list  of  the  events
253       whose  scripts  should be executed in the declared interpreter as well.
254       The contents of this option are ignored if the communication channel is
255       configured to execute received scripts in the current interpreter.
256
257   REMOTE INTERPRETERS
258       By  default,  each  channel is restricted to accepting connections from
259       the local system.  This can be overridden by using the -local 0 config‐
260       uration  option For such channels, the id parameter takes the form { id
261       host }.
262
263       WARNING: The host must always be specified in the same form  (e.g.,  as
264       either a fully qualified domain name, plain hostname or an IP address).
265
266   CLOSING CONNECTIONS
267       These methods give control over closing connections:
268
269       ::comm::comm shutdown id
270              This  closes the connection to id, aborting all outstanding com‐
271              mands in progress.  Note that nothing  prevents  the  connection
272              from  being immediately reopened by another incoming or outgoing
273              command.
274
275       ::comm::comm abort
276              This invokes shutdown on all open connections in this comm chan‐
277              nel.
278
279       ::comm::comm destroy
280              This  aborts  all  connections  and  then destroys the this comm
281              channel itself, including closing the listening socket.  Special
282              code  allows  the default ::comm::comm channel to be closed such
283              that the ::comm::comm command it is  not  destroyed.   Doing  so
284              closes the listening socket, preventing both incoming and outgo‐
285              ing commands on the channel.  This  sequence  reinitializes  the
286              default channel:
287
288
289                  "::comm::comm destroy; ::comm::comm new ::comm::comm"
290
291
292       When  a  remote connection is lost (because the remote exited or called
293       shutdown), comm can invoke an application callback.  This can  be  used
294       to cleanup or restart an ancillary process, for instance.  See the lost
295       callback below.
296
297   CALLBACKS
298       This is a mechanism for setting hooks for particular events:
299
300       ::comm::comm hook event ?+? ?script?
301              This uses a syntax similar  to  Tk's  bind  command.   Prefixing
302              script  with  a + causes the new script to be appended.  Without
303              this, a new script replaces any existing script.   When  invoked
304              without a script, no change is made.  In all cases, the new hook
305              script is returned by the command.
306
307              When an event occurs, the script associated with it is evaluated
308              with  the  listed  variables in scope and available.  The return
309              code (not the return value)  of  the  script  is  commonly  used
310              decide how to further process after the hook.
311
312              Common variables include:
313
314              chan   the name of the comm channel (and command)
315
316              id     the id of the remote in question
317
318              fid    the file id for the socket of the connection
319
320       These are the defined events:
321
322       connecting
323              Variables: chan, id
324
325              This  hook  is  invoked before making a connection to the remote
326              named in id.  An error return (via error) will abort the connec‐
327              tion attempt with the error.  Example:
328
329
330                  % ::comm::comm hook connecting {
331                      if {[string match {*[02468]} $id]} {
332                          error "Can't connect to even ids"
333                      }
334                  }
335                  % ::comm::comm send 10000 puts ok
336                  Connect to remote failed: Can't connect to even ids
337                  %
338
339
340       connected
341              Variables: chan, fid, id, host, and port.
342
343              This  hook  is invoked immediately after making a remote connec‐
344              tion to id, allowing arbitrary authentication  over  the  socket
345              named  by fid.  An error return (via error ) will close the con‐
346              nection with the error.  host and port are merely extracted from
347              the id; changing any of these will have no effect on the connec‐
348              tion, however.  It is also possible to  substitute  and  replace
349              fid.
350
351       incoming
352              Variables: chan, fid, addr, and remport.
353
354              Hook  invoked  when  receiving  an incoming connection, allowing
355              arbitrary authentication over socket named  by  fid.   An  error
356              return  (via  error)  will  close the connection with the error.
357              Note that the peer is named by remport and  addr  but  that  the
358              remote id is still unknown.  Example:
359
360
361                  ::comm::comm hook incoming {
362                      if {[string match 127.0.0.1 $addr]} {
363                          error "I don't talk to myself"
364                      }
365                  }
366
367
368       eval   Variables: chan, id, cmd, and buffer.
369
370              This  hook  is invoked after collecting a complete script from a
371              remote but before evaluating it.  This allows  complete  control
372              over  the  processing of incoming commands.  cmd contains either
373              send or async.  buffer holds the script  to  evaluate.   At  the
374              time the hook is called, $chan remoteid is identical in value to
375              id.
376
377              By changing buffer, the hook can change the script to be  evalu‐
378              ated.   The  hook can short circuit evaluation and cause a value
379              to be immediately returned by  using  return  result  (or,  from
380              within  a  procedure,  return  -code  return  result).  An error
381              return (via error) will return an error result,  as  is  if  the
382              script  caused  the  error.   Any other return will evaluate the
383              script in buffer as normal.  For compatibility with  3.2,  break
384              and  return -code break result is supported, acting similarly to
385              return {} and return -code return result.
386
387              Examples:
388
389              [1]    augmenting a command
390
391
392                         % ::comm::comm send [::comm::comm self] pid
393                         5013
394                         % ::comm::comm hook eval {puts "going to execute $buffer"}
395                         % ::comm::comm send [::comm::comm self] pid
396                         going to execute pid
397                         5013
398
399
400              [2]    short circuiting a command
401
402
403                         % ::comm::comm hook eval {puts "would have executed $buffer"; return 0}
404                         % ::comm::comm send [::comm::comm self] pid
405                         would have executed pid
406                         0
407
408
409              [3]    Replacing double eval semantics
410
411
412                         % ::comm::comm send [::comm::comm self] llength {a b c}
413                         wrong # args: should be "llength list"
414                         % ::comm::comm hook eval {return [uplevel #0 $buffer]}
415                         return [uplevel #0 $buffer]
416                         % ::comm::comm send [::comm::comm self] llength {a b c}
417                         3
418
419
420              [4]    Using a slave interpreter
421
422
423                         % interp create foo
424                         % ::comm::comm hook eval {return [foo eval $buffer]}
425                         % ::comm::comm send [::comm::comm self] set myvar 123
426                         123
427                         % set myvar
428                         can't read "myvar": no such variable
429                         % foo eval set myvar
430                         123
431
432
433              [5]    Using a slave interpreter (double eval)
434
435
436                         % ::comm::comm hook eval {return [eval foo eval $buffer]}
437
438
439              [6]    Subverting the script to execute
440
441
442                         % ::comm::comm hook eval {
443                             switch -- $buffer {
444                                 a {return A-OK}
445                                 b {return B-OK}
446                                 default {error "$buffer is a no-no"}
447                             }
448                         }
449                         % ::comm::comm send [::comm::comm self] pid
450                         pid is a no-no
451                         % ::comm::comm send [::comm::comm self] a
452                         A-OK
453
454
455       reply  Variables: chan, id, buffer, ret, and return().
456
457              This hook is invoked after collecting a  complete  reply  script
458              from  a  remote  but before evaluating it.  This allows complete
459              control over the processing of replies to  sent  commands.   The
460              reply buffer is in one of the following forms
461
462              ·      return result
463
464              ·      return -code code result
465
466              ·      return -code code -errorinfo info -errorcode ecode msg
467
468       For  safety  reasons, this is decomposed.  The return result is in ret,
469       and the return switches are in the return array:
470
471              ·      return(-code)
472
473              ·      return(-errorinfo)
474
475              ·      return(-errorcode)
476
477       Any of these may be the empty string.  Modifying these  four  variables
478       can change the return value, whereas modifying buffer has no effect.
479
480       callback
481              Variables: chan, id, buffer, ret, and return().
482
483              Similar to reply, but used for callbacks.
484
485       lost   Variables: chan, id, and reason.
486
487              This  hook is invoked when the connection to id is lost.  Return
488              value (or thrown error) is ignored.  reason  is  an  explanatory
489              string indicating why the connection was lost.  Example:
490
491
492                  ::comm::comm hook lost {
493                      global myvar
494                      if {$myvar(id) == $id} {
495                          myfunc
496                          return
497                      }
498                  }
499
500
501   UNSUPPORTED
502       These interfaces may change or go away in subsequence releases.
503
504       ::comm::comm remoteid
505              Returns the id of the sender of the last remote command executed
506              on this channel.  If used by a proc being invoked  remotely,  it
507              must  be  called  before  any  events are processed.  Otherwise,
508              another command may get invoked and change the value.
509
510       ::comm::comm_send
511              Invoking this procedure will substitute the Tk  send  and  winfo
512              interps commands with these equivalents that use ::comm::comm.
513
514
515                  proc send {args} {
516                      eval ::comm::comm send $args
517                  }
518                  rename winfo tk_winfo
519                  proc winfo {cmd args} {
520                      if {![string match in* $cmd]} {
521                          return [eval [list tk_winfo $cmd] $args]
522                      }
523                      return [::comm::comm interps]
524                  }
525
526
527   SECURITY
528       Something here soon.
529
530   BLOCKING SEMANTICS
531       There is one outstanding difference between comm and send.  When block‐
532       ing in a synchronous remote command,  send  uses  an  internal  C  hook
533       (Tk_RestrictEvents)  to  the  event loop to look ahead for send-related
534       events and only process those without processing any other events.   In
535       contrast,  comm  uses  the vwait command as a semaphore to indicate the
536       return message has arrived.  The difference is that a synchronous  send
537       will  block  the  application  and prevent all events (including window
538       related ones) from being processed, while  a  synchronous  ::comm::comm
539       send  will  block  the  application but still allow other events to get
540       processed.  In particular, after idle handlers  will  fire  immediately
541       when comm blocks.
542
543       What  can be done about this?  First, note that this behavior will come
544       from any code using vwait to block and wait for an event to occur.   At
545       the  cost  of  multiple  channel  support,  comm could be changed to do
546       blocking I/O on the socket, giving send-like blocking semantics.   How‐
547       ever, multiple channel support is a very useful feature of comm that it
548       is deemed too important to lose.  The remaining  approaches  involve  a
549       new loadable module written in C (which is somewhat against the philos‐
550       ophy of comm) One way would be to create  a  modified  version  of  the
551       vwait command that allow the event flags passed to Tcl_DoOneEvent to be
552       specified.  For comm, just  the  TCL_FILE_EVENTS  would  be  processed.
553       Another  way  would be to implement a mechanism like Tk_RestrictEvents,
554       but apply it to the Tcl event loop (since  comm  doesn't  require  Tk).
555       One  of  these approaches will be available in a future comm release as
556       an optional component.
557
558   ASYNCHRONOUS RESULT GENERATION
559       By default the result returned by a remotely  invoked  command  is  the
560       result  sent  back to the invoker. This means that the result is gener‐
561       ated synchronously, and the server handling the call is blocked for the
562       duration of the command.
563
564       While  this  is  tolerable  as  long as only short-running commands are
565       invoked on the server long-running commands, like database queries make
566       this  a problem. One command can prevent the processing requests of all
567       other clients for an arbitrary period of time.
568
569       Before version 4.5 of comm the only solution was to rewrite the  server
570       command  to  use the Tcl builtin command vwait, or one of its relatives
571       like tkwait, to open a new event loop which  processes  requests  while
572       the  long-running  operation is executed. This however has its own per‐
573       ils, as this makes it possible to both overflow the Tcl  stack  with  a
574       large  number  of  event  loop,  and to have a newer requests block the
575       return of older ones, as the eventloop have to be unwound in the  order
576       of their creation.
577
578       The  proper  solution  is  to have the invoked command indicate to comm
579       that it cannot or will not deliver an  immediate,  synchronous  result,
580       but  will  do so later. At that point the framework can put sending the
581       actual result on hold and continue processing requests using  the  main
582       event loop. No blocking, no nesting of event loops. At some future date
583       the long running operation delivers the result to comm, via the  future
584       object, which is then forwarded to the invoker as usual.
585
586       The  necessary  support  for this solution has been added to comm since
587       version 4.5, in the form of the new method return_async.
588
589       ::comm::comm return_async
590              This command is used by a remotely invoked script to notify  the
591              comm  channel  which  invoked it that the result to send back to
592              the invoker is not generated synchronously. If this  command  is
593              not called the default/standard behaviour of comm is to send the
594              synchronously generated result  of  the  script  itself  to  the
595              invoker.
596
597              The  result  of return_async is an object. This object, called a
598              future is where the result of the script has to be delivered  to
599              when  it  becomes  ready. When that happens it will take all the
600              necessary actions to deliver the result to the  invoker  of  the
601              script,  and then destroy itself. Should comm have lost the con‐
602              nection to the invoker while the result is  being  computed  the
603              future  will  not  try  to  deliver  the result it got, but just
604              destroy itself. The future can be configured with a  command  to
605              call  when  the invoker is lost. This enables the user to imple‐
606              ment an early abort of the long-running operation,  should  this
607              be supported by it.
608
609              An example:
610
611              # Procedure invoked by remote clients to run database operations.
612              proc select {sql} {
613                  # Signal the async generation of the result
614
615                  set future [::comm::comm return_async]
616
617                  # Generate an async db operation and tell it where to deliver the result.
618
619                  set query [db query -command [list $future return] $sql]
620
621                  # Tell the database system which query to cancel if the connection
622                  # goes away while it is running.
623
624                  $future configure -command [list db cancel $query]
625
626                  # Note: The above will work without problem only if the async
627                  # query will nover run its completion callback immediately, but
628                  # only from the eventloop. Because otherwise the future we wish to
629                  # configure may already be gone. If that is possible use 'catch'
630                  # to prevent the error from propagating.
631                  return
632              }
633
634
635              The API of a future object is:
636
637              $future return ?-code code? ?value?
638                     Use  this  method  to  tell  the future that long-running
639                     operation has completed. Arguments are an optional return
640                     value  (defaults to the empty string), and the Tcl return
641                     code (defaults to OK).
642
643                     The future will deliver this information to  invoker,  if
644                     the  connection  was  not  lost in the meantime, and then
645                     destroy itself. If the connection was  lost  it  will  do
646                     nothing but destroy itself.
647
648              $future configure ?-command ?cmdprefix??
649
650              $future cget -command
651                     These  methods  allow the user to retrieve and set a com‐
652                     mand to be called if the connection the future belongs to
653                     has been lost.
654
655   COMPATIBILITY
656       comm exports itself as a package.  The package version number is in the
657       form major . minor, where the major version will  only  change  when  a
658       non-compatible  change happens to the API or protocol.  Minor bug fixes
659       and changes will only affect the minor version.  To load comm this com‐
660       mand is usually used:
661
662           package require comm 3
663
664
665       Note  that  requiring  no  version  (or a specific version) can also be
666       done.
667
668       The revision history of comm includes these releases:
669
670       4.5.7  Changed handling of ports already in use  to  provide  a  proper
671              error message.
672
673       4.5.6  Bugfix  in  the  replacement  for  vwait, made robust against of
674              variable names containing spaces.
675
676       4.5.5  Bugfix in the handling of hooks, typo in variable name.
677
678       4.5.4  Bugfix in the handling  of  the  result  received  by  the  send
679              method.  Replaced  an  after idle unset result with an immediate
680              unset, with the information saved to a local variable.
681
682              The after idle can spill into a forked child process if there is
683              no  event loop between its setup and the fork. This may bork the
684              child if the next event loop is the vwait of comm's send  a  few
685              lines  above  the after idle, and the child used the same serial
686              number for its next request. In that  case  the  parent's  after
687              idle unset will delete the very array element the child is wait‐
688              ing for, unlocking the vwait, causing it to access a now missing
689              array element, instead of the expected result.
690
691       4.5.3  Bugfixes  in  the wrappers for the builtin update and vwait com‐
692              mands.
693
694       4.5.2  Bugfix in the wrapper for the builtin update command.
695
696       4.5.1  Bugfixes in the handling of -interp  for  regular  scripts.  The
697              handling  of the buffer was wrong for scripts which are a single
698              statement as list. Fixed missing argument to new  command  comm‐
699              SendReply, introduced by version 4.5. Affected debugging.
700
701       4.5    New  server-side  feature. The command invoked on the server can
702              now switch comm from the  standard  synchronous  return  of  its
703              result  to  an  asynchronous (defered) return. Due to the use of
704              snit to implement the future objects used by this  feature  from
705              this  version  on  comm requires at least Tcl 8.3 to run. Please
706              read  the  section  ASYNCHRONOUS  RESULT  GENERATION  for   more
707              details.
708
709       4.4.1  Bugfix in the execution of hooks.
710
711       4.4    Bugfixes  in  the  handling  of  -interp  for  regular  and hook
712              scripts. Bugfixes in channel cleanup.
713
714       4.3.1  Introduced -interp and -events to enable easy  use  of  a  slave
715              interp for execution of received scripts, and of event scripts.
716
717       4.3    Bugfixes,  and introduces -silent to allow the user to force the
718              server/listening side to  silently  ignore  connection  attempts
719              where the protocol negotiation failed.
720
721       4.2    Bugfixes,  and  most  important,  switched  to  utf-8 as default
722              encoding for full i18n without any problems.
723
724       4.1    Rewrite of internal code  to  remove  old  pseudo-object  model.
725              Addition of send -command asynchronous callback option.
726
727       4.0    Per  request  by  John  LoVerso.  Improved handling of error for
728              async invoked commands.
729
730       3.7    Moved into tcllib and placed in a proper namespace.
731
732       3.6    A bug in the looking up of the remoteid for a  executed  command
733              could  be triggered when the connection was closed while several
734              asynchronous sends were queued to be executed.
735
736       3.5    Internal change to how reply messages from a send  are  handled.
737              Reply messages are now decoded into the value to pass to return;
738              a new return statement is then cons'd up  to  with  this  value.
739              Previously,  the  return code was passed in from the remote as a
740              command to evaluate.  Since the wire protocol has  not  changed,
741              this  is  still  the  case.   Instead,  the  reply handling code
742              decodes the reply message.
743
744       3.4    Added more source commentary,  as  well  as  documenting  config
745              variables  in  this man page.  Fixed bug were loss of connection
746              would give error about a variable named pending rather than  the
747              message about the lost connection.  comm ids is now an alias for
748              comm interps (previously, it an alias for  comm  chans).   Since
749              the method invocation change of 3.0, break and other exceptional
750              conditions were not being returned  correctly  from  comm  send.
751              This  has  been fixed by removing the extra level of indirection
752              into the internal procedure commSend.  Also added propagation of
753              the  errorCode  variable.  This means that these commands return
754              exactly as they would with send:
755
756
757                  comm send id break
758                  catch {comm send id break}
759                  comm send id expr 1 / 0
760
761
762              Added a new hook for reply messages.  Reworked method invocation
763              to avoid the use of comm:* procedures; this also cut the invoca‐
764              tion time down by 40%.  Documented comm config (as  this  manual
765              page still listed the defunct comm init!)
766
767       3.3    Some minor bugs were corrected and the documentation was cleaned
768              up.  Added some examples for hooks.  The return semantics of the
769              eval hook were changed.
770
771       3.2    A  new  wire  protocol, version 3, was added.  This is backwards
772              compatible with version 2 but adds an exchange of supported pro‐
773              tocol  versions  to  allow  protocol  negotiation in the future.
774              Several bugs with the hook implementation  were  fixed.   A  new
775              section of the man page on blocking semantics was added.
776
777       3.1    All  the  documented  hooks  were implemented.  commLostHook was
778              removed.  A bug in comm new was fixed.
779
780       3.0    This is a new version of comm with several major changes.  There
781              is  a  new  way of creating the methods available under the comm
782              command.  The comm init method has been retired and is  replaced
783              by  comm  configure  which  allows  access  to many of the well-
784              defined internal variables.  This also generalizes  the  options
785              available to comm new.  Finally, there is now a protocol version
786              exchanged when a connection is established.  This will allow for
787              future  on-wire  protocol changes.  Currently, the protocol ver‐
788              sion is set to 2.
789
790       2.3    comm ids was renamed to comm channels.  General support for comm
791              hook  was  fully implemented, but only the lost hook exists, and
792              it was changed to follow the general hook API.  commLostHook was
793              unsupported  (replaced  by  comm  hook  lost)  and  commLost was
794              removed.
795
796       2.2    The died hook was renamed lost, to be accessed  by  commLostHook
797              and  an  early  implementation of comm lost hook.  As such, com‐
798              mDied is now commLost.
799
800       2.1    Unsupported method comm remoteid was added.
801
802       2.0    comm has been rewritten from scratch (but  is  fully  compatible
803              with Comm 1.0, without the requirement to use obTcl).
804

AUTHOR

806       John LoVerso, John@LoVerso.Southborough.MA.US
807
808       http://www.opengroup.org/~loverso/tcl-tk/#comm
809

LICENSE

811       Please  see  the  file  comm.LICENSE  that  accompanied this source, or
812       http://www.opengroup.org/www/dist_client/caubweb/COPYRIGHT.free.html.
813
814       This license for comm, new as of version 3.2, allows it to be used  for
815       free, without any licensing fee or royalty.
816

BUGS

818       ·      If  there  is  a  failure  initializing  a  channel created with
819              ::comm::comm new, then the channel should  be  destroyed.   Cur‐
820              rently, it is left in an inconsistent state.
821
822       ·      There  should be a way to force a channel to quiesce when chang‐
823              ing the configuration.
824
825       The following items can be implemented with the existing hooks and  are
826       listed here as a reminder to provide a sample hook in a future version.
827
828       ·      Allow  easier use of a slave interp for actual command execution
829              (especially when operating in "not local" mode).
830
831       ·      Add  host  list  (xhost-like)  or  "magic  cookie"  (xauth-like)
832              authentication to initial handshake.
833
834       The following are outstanding todo items.
835
836       ·      Add  an interp discovery and name->port mapping.  This is likely
837              to be in a separate, optional nameserver.  (See also the related
838              work, below.)
839
840       ·      Fix  the {id host} form so as not to be dependent upon canonical
841              hostnames.  This requires fixes to Tcl to resolve hostnames!
842
843       This man page is bigger than the source file.
844

ON USING OLD VERSIONS OF TCL

846       Tcl7.5 under Windows contains a bug that causes the interpreter to hang
847       when  EOF  is  reached  on non-blocking sockets.  This can be triggered
848       with a command such as this:
849
850           "comm send $other exit"
851
852
853       Always make sure the channel is quiescent before closing/exiting or use
854       at least Tcl7.6 under Windows.
855
856       Tcl7.6  on the Mac contains several bugs.  It is recommended you use at
857       least Tcl7.6p2.
858
859       Tcl8.0 on UNIX contains a socket bug that can crash Tcl.  It is  recom‐
860       mended you use Tcl8.0p1 (or Tcl7.6p2).
861
863       Tcl-DP  provides an RPC-based remote execution interface, but is a com‐
864       piled       Tcl        extension.         See        http://www.cs.cor
865       nell.edu/Info/Projects/zeno/Projects/Tcl-DP.html.
866
867       Michael Doyle <miked@eolas.com> has code that implements the Tcl-DP RPC
868       interface using standard Tcl sockets, much like comm.
869
870       Andreas Kupries <andreas_kupries@users.sourceforge.net> uses  comm  and
871       has  built  a  simple  nameserver  as  part  of  his Pool library.  See
872       http://www.purl.org/net/akupries/soft/pool/index.htm.
873

BUGS, IDEAS, FEEDBACK

875       This document, and the package it describes, will  undoubtedly  contain
876       bugs  and  other  problems.  Please report such in the category comm of
877       the         Tcllib         SF         Trackers          [http://source
878       forge.net/tracker/?group_id=12883].   Please  also report any ideas for
879       enhancements you may have for either package and/or documentation.
880

SEE ALSO

882       send(n)
883
885       Copyright (c) 1995-1998 The Open Group. All Rights Reserved.
886       Copyright (c) 2003-2004 ActiveState Corporation.
887       Copyright (c) 2006-2007 Andreas Kupries <andreas_kupries@users.sourceforge.net>
888
889
890
891
892comm                                 4.5.7                             comm(n)
Impressum