4.13 Sockets and Socket Management These words provide the basic socket management procedures described in Volume 1 of this Specification. !PLUG-CONTROL store-plug-control T (Sequence) ( xp - ) Establish xp as the current procedure for validating socket plug actions. The sequence may be implemented as: 0 PLUGSOCKET SETEQ ELIT INVALID-NUMERIC-ARG QTHROW INTO C,I (Sequence) Interpretation: ( xp"name" ) Place xp into the socket list position corresponding to name. Compilation: ( "name") Append to the current definition a token stream providing the execution seman-tics defined below. Execution: ( xp - flag ) Attempt to plug xp into the socket corresponding to name, and return a false flag if the action was disallowed. The sequence may be implemented as LIT PLUGSOCKET. Normally used with PLUG, as follows: 10 SOCKET FUNC ... : OP DROP ; Then, PLUG OP INTO FUNC stores the execution pointer for OP in the socket FUNC. Subsequent use of FUNC will cause OP to be executed if the PLUG succeeded. All words defined for use in sockets other than socket zero must have no stack effect. The socket-control procedure which is plugged into socket zero takes a socket number from the stack and returns a flag, indicating whether the given socket may be modified. PLUG C,I ELITC <+addr> Interpretation: ( "name" - xp ) Return the execution pointer for name. Normally used to provide a value to be plugged into a socket by INTO. Compilation: ("name" - ) Compile the execution pointer for name. Execution: ( - xp ) Return the execution pointer for name. SOCKET I DOSOCKET ( num "name" - ) Define a named procedure associated with socket num (0-63). When name is invoked, the procedure whose execution pointer is presently in socket num will be executed. The behaviour associated with a socket may be specified using PLUG and INTO. All words whose behaviour may be associated with a SOCKET must have no stack effects. name Execution:( - ) Execute the definition whose execution pointer has been associated with name using PLUG ... INTO. For example: 31 SOCKET TRM\ Defines socket 31 : MY-TRM ; \ Local TRM function ... PLUG MY-TRM INTO TRM \ At initialisation