home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / PIPES.ZIP / PIPES.HLP (.txt) < prev    next >
OS/2 Help File  |  1990-01-08  |  24KB  |  904 lines

  1.  
  2. ΓòÉΓòÉΓòÉ 1. Named Pipe Demo Overview ΓòÉΓòÉΓòÉ
  3.  
  4. The Named Pipes Demo program was written in order to provide OS2/PM programmers 
  5. with a working example of the coding requirements and functional 
  6. characteristics of named pipe processing. 
  7.  
  8. The following overview topics may be selected: 
  9.  
  10.  o What is a Named Pipe? 
  11.  o Restrictions 
  12.  o Method of Operation 
  13.  o Handshaking 
  14.  
  15.  
  16. ΓòÉΓòÉΓòÉ 1.1. Restrictions ΓòÉΓòÉΓòÉ
  17.  
  18. This demonstration module has been written in order to allow a programmer to 
  19. get some "hands on" experience with the operation of OS2 named pipes.  All of 
  20. the non-semaphore related operations have been included in the application. 
  21.  
  22. The demo constructs pipes with the following characteristics: 
  23.  
  24.  o Duplex pipe 
  25.  o Input  buffersize 512 
  26.  o Output buffersize 512 
  27.  o Pipe operations will block 
  28.  o Write behind will not be allowed 
  29.  o Unlimited instances 
  30.  o Message write mode 
  31.  o Message read  mode 
  32.  o Maximum of 8 characters for Pipe Name and Server name 
  33.  
  34.  The demo has been constructed in such a way that you can initiate sequences 
  35.  that are not valid in pipe processing.  For example, there is nothing to stop 
  36.  you from trying to read from a pipe that you have not opened.  By doing these 
  37.  things, you can see the effect in the demo before you have to code for it in a 
  38.  program. 
  39.  
  40.  There are some operations that are disabled to protect you from  disaster. 
  41.  You can not select either Client or Server functions until you have specified 
  42.  the pipe name and type.  Once you specify Client type you can not  select 
  43.  Server functions.  Once you select Server type you can not select Client 
  44.  functions.  Once you open or make a pipe you can not re-open, re-make, or Name 
  45.  the pipe again until the pipe has been closed.  Otherwise, the pipe calls you 
  46.  can perform are wide open. 
  47.  
  48.  
  49. ΓòÉΓòÉΓòÉ 1.2. Method of Operation ΓòÉΓòÉΓòÉ
  50.  
  51. The first thing you must do in the demo is identify the name of the pipe.  The 
  52. default name is Kiddo (the nickname my daughter once insisted upon ldl.)  Then 
  53. you must choose from one of the three named pipe modes: 
  54.  
  55.  o LOCAL CLIENT mode sets the demo so that it will operate with another demo 
  56.    process running on YOUR PC that has been set to run in server mode. 
  57.  o REMOTE CLIENT mode sets the demo so that it will operate with another demo 
  58.    process running on your PC or another PC in your LAN.  If you select this 
  59.    item, the server process must be running on a PC that has been properly 
  60.    configured to respond as a server in the LAN.  You MUST provide that PC's 
  61.    remote server name (COMPUTERNAME) at the time of remote client mode 
  62.    selection. 
  63.  o SERVER mode sets the demo so that it will operate with another demo process 
  64.    running in either local or remote client modes. 
  65.  
  66.  Once you have set the name and mode of the demo pipe process, you can select 
  67.  either Client or Server action bar items from the Process action bar as is 
  68.  appropriate for your chosen mode. 
  69.  
  70.  As soon as you have established one end of the pipe, you need to start a 
  71.  process that will deal with the other end of the pipe.  If you are using ONLY 
  72.  one PC, select CLONE from the PROCESS action bar.  This will start another 
  73.  copy of the demo with which you may proceed.  If you are using TWO PCs in a 
  74.  LAN, you should go to the other PC and start a copy of the demo there. 
  75.  
  76.  
  77. ΓòÉΓòÉΓòÉ 1.3. Handshaking ΓòÉΓòÉΓòÉ
  78.  
  79. Named pipe processing has various requirements for correct processing and you 
  80. are encouraged to read the apropriate sections of the OS2 Programming Guide 
  81. before and during the demo.  If you are using IBM part number 64F0273, see 
  82. pages 35-11 through 35-17. 
  83.  
  84. In general, here is enough to get you started: 
  85.  
  86.  o The Server process must make the pipe. 
  87.  o The Server process must connect the pipe. 
  88.  o The Client process must open the pipe. 
  89.  o Both pipes may now read, write and do whatever.  It should be noted that 
  90.    pipe communication protocols are specific to the application.  (ie. There 
  91.    are no "First Speaker/Second Speaker" or other flow control features the 
  92.    programmer may be used to using in SNA or elsewhere.) 
  93.  
  94.  State, Info, and Peek selections on the File action bar will complete without 
  95.  error once the pipe is made or opened. 
  96.  
  97.  
  98. ΓòÉΓòÉΓòÉ 1.4. What is a Named Pipe? ΓòÉΓòÉΓòÉ
  99.  
  100. A named pipe is an OS2 construct that allows two processes to communicate data. 
  101. There are several ways to communicate data between processes in OS2.  The most 
  102. effecient way to share data between processes running on the same PC is to 
  103. allocate and share memory.  What named pipes brings to the table is an ability 
  104. to share data between processes running on two different PC's in the same Local 
  105. Area Network.  This ability is the basis for Client/Server distributive 
  106. processing on the OS2 platform. 
  107.  
  108. The way in which named pipes has been implimented in OS2 is relatively painless 
  109. for the application developer.  In a nutshell, named pipes interfaces mirror 
  110. file I/O processing.  The server process makes the pipe in a fashion similar to 
  111. creating a file.  The client process opens the named pipe using the same call 
  112. that would be made to open a file.  From that point on, both client and server 
  113. read and write to the pipe just as they would to a file.  The big difference is 
  114. that the "file" has intelligence as an application.  The record that the client 
  115. writes to the pipe is read by the server and processed in some fashion.  The 
  116. server may then respond to the client message (record) by writing to the pipe 
  117. information that the client may read from the pipe. 
  118.  
  119. Named pipes can be defined with several variations.  You are encouraged to read 
  120. the apropriate sections of the OS2 Programming Guide before and during the 
  121. demo.  If you are using IBM part number 64F0273, see pages 35-11 through 35-17. 
  122.  
  123. For your immediate information, this demo uses a DUPLEX pipe.  A duplex pipe 
  124. allows I/O in both directions from the same pipe.  The demo pipe allows 
  125. blocking.  Blocking means that several pipe functions (connect, wait, read, 
  126. write, etc.) will suspend the caller if the function is not immediately 
  127. executable.  That means that if you issue a read and there is no data in the 
  128. pipe you will wait until there is.  That's great in terms of relieving you of 
  129. the responsibility of writing retry routines for mundane processing.  However, 
  130. you must not allow window or dialog message processing routines to wait.  If 
  131. you do, the user's PC will lock up until the pipe block is relieved.  The demo 
  132. has implimented a relatively crude, but effective, method to circumvent this 
  133. problem using asynchronous threads in conjunction with modeless dialogs. 
  134.  
  135. There are two types of I/O processing that may be done using named pipes, BYTE 
  136. stream and MESSAGE stream.  This demo uses message stream processing. Message 
  137. stream processing, simply put, allows you to read and write at the  record 
  138. level.  There may be some instance that makes byte level I/O more attractive 
  139. for an application.  However, I can't think of any. 
  140.  
  141.  
  142. ΓòÉΓòÉΓòÉ 2. Named Pipe Primary Window ΓòÉΓòÉΓòÉ
  143.  
  144. This is the demo primary help panel. 
  145.  
  146. The following Topics may be selected from this menu: 
  147.  
  148.  Overview:      Purpose and function 
  149.  
  150.  Action Bar Items 
  151.  
  152.  o File 
  153.  o Process 
  154.  o Help 
  155.  
  156.  Panels 
  157.  
  158.  o Pipes Control 
  159.  o Client Functions 
  160.  o Server Functions 
  161.  o Pipe State 
  162.  o Pipe Info 
  163.  o Peek Pipe 
  164.  o Message from Pipe 
  165.  o Message to Pipe 
  166.  o Async Thread Panel 
  167.  
  168.  
  169. ΓòÉΓòÉΓòÉ 2.1. File Action Bar Selection ΓòÉΓòÉΓòÉ
  170.  
  171. Named Pipe I/O is very similar to file I/O, so the File action bar selection is 
  172. appropriately named.  From the File action bar you may select one of the 
  173. following action items: 
  174.  
  175.  Name:          Set Pipe Name and Type 
  176.  State:         DosQNmPHandState 
  177.  Info:          DosQNmPipeInfo 
  178.  Peek:          DosPeekNmPipe 
  179.  Exit:          Exit Demo 
  180.  
  181.  
  182. ΓòÉΓòÉΓòÉ 2.1.1. Set Pipe Name and Type ΓòÉΓòÉΓòÉ
  183.  
  184. The Name action item selection on the File action bar allows you to display the 
  185. Pipes Control  panel.  From there you may enter the name of the pipe that the 
  186. demo will use and the type of pipe it should process. 
  187.  
  188.  
  189. ΓòÉΓòÉΓòÉ 2.1.2. DosQNmPHandState ΓòÉΓòÉΓòÉ
  190.  
  191. The State action item selection on the File action bar executes 
  192. DosQNmPHandState for the named pipe being processed and presents panel Pipe 
  193. State. 
  194.  
  195.  
  196. ΓòÉΓòÉΓòÉ 2.1.3. DosQNmPipeInfo ΓòÉΓòÉΓòÉ
  197.  
  198. The Info action item selection on the File action bar executes DosQNmPipeInfo 
  199. for the  named pipe being processed and presents panel Pipe Info. 
  200.  
  201.  
  202. ΓòÉΓòÉΓòÉ 2.1.4. DosPeekNmPipe ΓòÉΓòÉΓòÉ
  203.  
  204. The Peek action item selection on the File action bar executes DosPeekNmPipe 
  205. for the  named pipe being processed and presents panel Pipe Peek. 
  206.  
  207.  
  208. ΓòÉΓòÉΓòÉ 2.1.5. Exit ΓòÉΓòÉΓòÉ
  209.  
  210. The Exit action item selection on the File action bar quits the program. 
  211.  
  212.  
  213. ΓòÉΓòÉΓòÉ 2.2. Process Action Bar Selection ΓòÉΓòÉΓòÉ
  214.  
  215. The Process action bar selection allows you access to client and server pipe 
  216. functions as well as enabling you to start another PIPES DEMO process to play 
  217. with local pipes. 
  218.  
  219. From the Process action bar you may select the following action items: 
  220.  
  221.  Client         open, close, etc. 
  222.  Server         make, close, etc. 
  223.  Clone          Start another process. 
  224.  
  225.  
  226. ΓòÉΓòÉΓòÉ 2.2.1. Client Functions ΓòÉΓòÉΓòÉ
  227.  
  228. The Client action item selection on the Process action bar allows you to 
  229. perform operations that are valid for the client end of the pipe. 
  230.  
  231.  
  232. ΓòÉΓòÉΓòÉ 2.2.2. Server Functions ΓòÉΓòÉΓòÉ
  233.  
  234. The Server action item selection on the Process action bar allows you to 
  235. perform operations that are valid for the server end of the pipe. You may 
  236. accomplish these using panel Server Functions. 
  237.  
  238.  
  239. ΓòÉΓòÉΓòÉ 2.2.3. Clone ΓòÉΓòÉΓòÉ
  240.  
  241. The Clone action item selection on the Process action bar allows you to start 
  242. another demo session in order to use the demo to process both sides of a local 
  243. pipe.  You can also create multiple servers and/or clients to emulate more 
  244. complex pipe environments. 
  245.  
  246.  
  247. ΓòÉΓòÉΓòÉ 2.3. Help Action Bar Selection ΓòÉΓòÉΓòÉ
  248.  
  249. This action bar item allows you to select functions from the help subsystem. 
  250.  
  251. Valid help subsystem action items are: 
  252.  
  253.  Help for help  explains help functions in detail 
  254.  Extended Help  retrieves pipes demo  primary help panel 
  255.  Keys Help      explains use of special key combinations 
  256.  Help Index     presents help topics in an indexed list 
  257.  About Demo     displays program version and author info 
  258.  
  259.  
  260. ΓòÉΓòÉΓòÉ 2.3.1. Help for help ΓòÉΓòÉΓòÉ
  261.  
  262. This action bar item allows you to request instructions regarding the use of 
  263. the help subsystem. 
  264.  
  265.  
  266. ΓòÉΓòÉΓòÉ 2.3.2. Extended Help ΓòÉΓòÉΓòÉ
  267.  
  268. This action bar item allows you to request general help about the active 
  269. application window. 
  270.  
  271.  
  272. ΓòÉΓòÉΓòÉ 2.3.3. Keys Help ΓòÉΓòÉΓòÉ
  273.  
  274. This action bar item allows you to request instructions about special key 
  275. functions. 
  276.  
  277.  
  278. ΓòÉΓòÉΓòÉ 2.3.4. Help Index ΓòÉΓòÉΓòÉ
  279.  
  280. This action bar item allows you to access the index of Help topics. 
  281.  
  282.  
  283. ΓòÉΓòÉΓòÉ 2.3.5. About ΓòÉΓòÉΓòÉ
  284.  
  285. This action bar item displays the active application program version level and 
  286. author. 
  287.  
  288.  
  289. ΓòÉΓòÉΓòÉ 3. Pipes Control Panel ΓòÉΓòÉΓòÉ
  290.  
  291. The Pipes Control panel is used to set the demo global parameters.  You must 
  292. complete this panel before you may exercise pipe functions. 
  293.  
  294. Controls on this panel are: 
  295.  
  296.  Pipe Name      Set name of pipe 
  297.  Computername   Identify remote server 
  298.  Local Client   Set mode to local client 
  299.  Remote Client  Set mode to remote client 
  300.  Server         Set mode to server 
  301.  OK             Execute specifications 
  302.  Cancel         Ignore specifcations 
  303.  
  304.  
  305. ΓòÉΓòÉΓòÉ 3.1. Pipe Name ΓòÉΓòÉΓòÉ
  306.  
  307. The Pipe Name is used to identify the Pipe resource to the processes that are 
  308. using it.  This is a required field. 
  309.  
  310.  
  311. ΓòÉΓòÉΓòÉ 3.2. Computername ΓòÉΓòÉΓòÉ
  312.  
  313. In order to connect a remote client with a server on another PC, you must 
  314. specify the name with which that PC has identified itself to the network 
  315. (COMPUTERNAME).  This field is required if you specify a mode of  Remote 
  316. Client. 
  317.  
  318.  
  319. ΓòÉΓòÉΓòÉ 3.3. Local Client Pipe Radio Button ΓòÉΓòÉΓòÉ
  320.  
  321. Selecting a local client type of pipe allows you to connect with a server 
  322. process on your PC. 
  323.  
  324.  
  325. ΓòÉΓòÉΓòÉ 3.4. Server Pipe Radio Button ΓòÉΓòÉΓòÉ
  326.  
  327. Selecting a server type of pipe sets the mode to server in the demo process. 
  328.  
  329.  
  330. ΓòÉΓòÉΓòÉ 3.5. Remote Client Pipe Radio Button ΓòÉΓòÉΓòÉ
  331.  
  332. Selecting a remote server type allows you to connect to server demo processes 
  333. that are running your PC or on other PC's in the network.  If you select this 
  334. pipe mode you must specify Computername. 
  335.  
  336.  
  337. ΓòÉΓòÉΓòÉ 3.6. OK Button ΓòÉΓòÉΓòÉ
  338.  
  339. The OK button executes items selected and input on the Pipes Control panel. 
  340.  
  341.  
  342. ΓòÉΓòÉΓòÉ 3.7. Cancel Button ΓòÉΓòÉΓòÉ
  343.  
  344. The Cancel button ignores any changes or inputs on the Pipes Control panel. 
  345.  
  346.  
  347. ΓòÉΓòÉΓòÉ 4. Client Functions Panel ΓòÉΓòÉΓòÉ
  348.  
  349. The Client Functions panel allows you to invoke pipe functions that are valid 
  350. for processes owning the client end of a named pipe. 
  351.  
  352. Valid Client named pipe functions are: 
  353.  
  354.  Open           Open a named pipe 
  355.  Wait           Wait for available pipe instance 
  356.  Read           Wait for server message 
  357.  Write          Send pipe message 
  358.  Close          Deallocate pipe resource 
  359.  
  360.  Other controls: 
  361.  
  362.  Ok             Execute selection 
  363.  Cancel         Ignore selection 
  364.  
  365.  
  366. ΓòÉΓòÉΓòÉ 4.1. Open Radio Button ΓòÉΓòÉΓòÉ
  367.  
  368. The Open radio button on panel Client Functions  allows you to open a named 
  369. pipe by call DosOpen.  Various pipe control parameters are hard coded within 
  370. the  program.  You may use State and Info from the Files action bar to 
  371. determine the pipe parameters used. 
  372.  
  373. Once the pipe has been opened, the Open radio button is disabled (until the 
  374. pipe has been closed.)  This is done so that you do not inadvertantly destroy 
  375. the pipe handle. 
  376.  
  377.  
  378. ΓòÉΓòÉΓòÉ 4.2. Wait Radio Button ΓòÉΓòÉΓòÉ
  379.  
  380. The Wait radio button on panel Client Functions  allows you to create a 
  381. sub-task (thread) for your process that issues  DosWaitNmPipe to wait for a 
  382. server process to issue a make and connect for its end of the named pipe.  You 
  383. should only use the wait function if you receive an ERROR_PIPE_BUSY return from 
  384. DosOpen.  You will receive this return code when: 
  385.  
  386.  o The server has made the pipe and not yet issued the connect for it. 
  387.  o All existing instances of the named pipe have already been opened by other 
  388.    client processes. 
  389.  
  390.  An asynchronous thread is required for this purpose because the pipe was 
  391.  created using blocked mode.  (See State action item selection.) 
  392.  
  393.  
  394. ΓòÉΓòÉΓòÉ 4.3. Read Radio Button ΓòÉΓòÉΓòÉ
  395.  
  396. The Read radio button on panel Client Functions  allows you to create a 
  397. sub-task (thread) for your process that issues a  DosRead and waits for a 
  398. message to be received from the server end of the pipe. 
  399.  
  400. An asynchronous thread is required for this purpose because the pipe was 
  401. created using blocked mode.  (See State action item selection.) 
  402.  
  403. When DosRead returns with a non-zero length message, you are presented with 
  404. panel Message from Pipe that displays the  message that was received. 
  405.  
  406.  
  407. ΓòÉΓòÉΓòÉ 4.4. Write Radio Button ΓòÉΓòÉΓòÉ
  408.  
  409. The Write radio button on panel Client Functions  allows you to input a 
  410. multiline text message using panel  "Message to Pipe."  Once you enter the 
  411. message text, a sub-task (thread) is created for your process issues DosWrite 
  412. to write the message and waits for the write to the pipe to complete. 
  413.  
  414. An asynchronous thread is required for this purpose because the pipe was 
  415. created using blocked mode.  (See State action item selection.) 
  416.  
  417.  
  418. ΓòÉΓòÉΓòÉ 4.5. Close Radio Button. ΓòÉΓòÉΓòÉ
  419.  
  420. The Close radio button on panel Client Functions  allows you to issue the 
  421. DosClose call for the named pipe resource.  DosClose will deallocate the pipe 
  422. resource for your client process.  It will not flush any unread server 
  423. messages. 
  424.  
  425. A DosPeekNmPipe issued by the server will indicate that the pipe is in a 
  426. "closing" state.  The server may continue to read messages that are buffered in 
  427. the pipe until no more messages remain.  A read on the empty pipe will return 
  428. EOF. 
  429.  
  430.  
  431. ΓòÉΓòÉΓòÉ 4.6. OK Button ΓòÉΓòÉΓòÉ
  432.  
  433. The OK button executes items selected the Client Functions panel. 
  434.  
  435.  
  436. ΓòÉΓòÉΓòÉ 4.7. Cancel Button ΓòÉΓòÉΓòÉ
  437.  
  438. The Cancel button ignores items selected on the Client Functions panel. 
  439.  
  440.  
  441. ΓòÉΓòÉΓòÉ 5. Server Functions Panel ΓòÉΓòÉΓòÉ
  442.  
  443. The Server Functions panel allows you to invoke pipe functions that are valid 
  444. for processes owning the server end of a named pipe. 
  445.  
  446. Valid Server named pipe functions are: 
  447.  
  448.  Make           Create a named pipe 
  449.  Connect        Wait for client to open 
  450.  Read           Wait for client message 
  451.  Write          Send pipe message 
  452.  Disconnect     Break client connection 
  453.  Close          Deallocate pipe resource 
  454.  
  455.  Other controls: 
  456.  
  457.  Ok             Execute selection 
  458.  Cancel         Ignore selection 
  459.  
  460.  
  461. ΓòÉΓòÉΓòÉ 5.1. Make Radio Button ΓòÉΓòÉΓòÉ
  462.  
  463. The Make radio button on panel Server Functions  allows you to create a named 
  464. pipe by call DosMakeNmPipe. Various pipe control parameters are hard coded 
  465. within the  program.  You may use State and Info from the Files action bar to 
  466. determine the pipe parameters used. 
  467.  
  468. Once the pipe has been made, the Make radio button is disabled (until the  pipe 
  469. has been closed.)  This is done so that you do not inadvertantly destroy the 
  470. pipe handle. 
  471.  
  472.  
  473. ΓòÉΓòÉΓòÉ 5.2. Connect Radio Button ΓòÉΓòÉΓòÉ
  474.  
  475. The Connect radio button on panel Server Functions  allows you to create a 
  476. sub-task (thread) for your process that issues  DosConnectNmPipe to wait for a 
  477. client process to open its end of the named pipe. 
  478.  
  479. An asynchronous thread is required for this purpose because the pipe was 
  480. created using blocked mode.  (See State action item selection.) 
  481.  
  482.  
  483. ΓòÉΓòÉΓòÉ 5.3. Read Radio Button ΓòÉΓòÉΓòÉ
  484.  
  485. The Read radio button on panel Server Functions  allows you to create a 
  486. sub-task (thread) for your process that issues a  DosRead and waits for a 
  487. message to be received from the client end of the pipe. 
  488.  
  489. An asynchronous thread is required for this purpose because the pipe was 
  490. created using blocked mode.  (See State action item selection.) 
  491.  
  492. When DosRead returns with a non-zero length message, you are presented with 
  493. panel Message from Pipe that displays the  message that was received. 
  494.  
  495.  
  496. ΓòÉΓòÉΓòÉ 5.4. Write Radio Button ΓòÉΓòÉΓòÉ
  497.  
  498. The Write radio button on panel Server Functions  allows you to input a 
  499. multiline text message using panel  "Message to Pipe."  Once you enter the 
  500. message text, a sub-task (thread) is created for your process issues DosWrite 
  501. to write the message and waits for the write to the pipe to complete. 
  502.  
  503. An asynchronous thread is required for this purpose because the pipe was 
  504. created using blocked mode.  (See State action item selection.) 
  505.  
  506.  
  507. ΓòÉΓòÉΓòÉ 5.5. Disconnect Radio Button ΓòÉΓòÉΓòÉ
  508.  
  509. The Disconnect radio button on panel Server Functions  allows you to execute 
  510. DosDisConnectNmPipe for the named pipe that you made.  Disconnect flushes any 
  511. messages that you have written but have not been read by the client from the 
  512. pipe.  The next read issued by the client will return ERROR_PIPE_DISCONNECTED. 
  513.  
  514. After you disconnect the pipe, you may Close it (completely deallocate the 
  515. resource) or you may re-issue the Connect to accept a new client open. 
  516.  
  517.  
  518. ΓòÉΓòÉΓòÉ 5.6. Close Radio Button. ΓòÉΓòÉΓòÉ
  519.  
  520. The Close radio button on panel Server Functions  allows you to issue the 
  521. DosClose call for the named pipe resource.  DosClose will deallocate the pipe 
  522. resource for your server process.  It will not flush any unread client 
  523. messages. 
  524.  
  525. A DosPeekNmPipe issued by the client will indicate that the pipe is in a 
  526. "closing" state.  The client may continue to read messages that are buffered in 
  527. the pipe until no more messages remain.  A read on the empty pipe will return 
  528. EOF. 
  529.  
  530.  
  531. ΓòÉΓòÉΓòÉ 5.7. OK Button ΓòÉΓòÉΓòÉ
  532.  
  533. The OK button executes items selected on the Server Functions panel. 
  534.  
  535.  
  536. ΓòÉΓòÉΓòÉ 5.8. Cancel Button ΓòÉΓòÉΓòÉ
  537.  
  538. The Cancel button ignores items selected on the Server Functions panel. 
  539.  
  540.  
  541. ΓòÉΓòÉΓòÉ 6. Message from Pipe Panel ΓòÉΓòÉΓòÉ
  542.  
  543. When a DosRead returns with a message length greater than zero, the Message 
  544. from Pipe panel presents the message in a multi-line edit dialog control. 
  545.  
  546. Both the OK and Cancel buttons serve only to end the dialog and return you to 
  547. the application window. 
  548.  
  549.  
  550. ΓòÉΓòÉΓòÉ 7. Message to Pipe Panel ΓòÉΓòÉΓòÉ
  551.  
  552. When you select the Write radio button from either the Client or Server 
  553. Function panels, you are presented with the Message to Pipe panel.  You can 
  554. enter text in the multi-line edit dialog control on the panel.  Lines will 
  555. automatically wrap at word boundaries.  The scroll bar control will activate if 
  556. you enter more lines than can be displayed in the edit area.  You may enter 
  557. messages of up to 510 characters.  You may not enter zero length messages.  If 
  558. you decide not to send a message, you may press the cancel button.  Otherwise, 
  559. press the OK button. 
  560.  
  561. Pressing the OK button causes the demo to start an asynchronous task (thread) 
  562. that writes the message to the pipe using DosWrite. 
  563.  
  564. An asynchronous thread is required for this purpose because the pipe was 
  565. created using blocked mode.  (See State action item selection.) 
  566.  
  567.  
  568. ΓòÉΓòÉΓòÉ 8. Asychronous Thread Panel ΓòÉΓòÉΓòÉ
  569.  
  570. The Asynchronous Thread panel is displayed when you select a function that has 
  571. the potential to block. 
  572.  
  573. The following pipe functions may block during execution: 
  574.  
  575.  Connect        DosConnectNmPipe 
  576.  Wait           DosWaitNmPipe 
  577.  Read           DosRead 
  578.  Write          DosWrite 
  579.  
  580.  Blocking simply means that if the operation can not be performed imediately, 
  581.  the issuer waits until it completes.  By using blocking, you do not have to 
  582.  develop methods to retry failed operations.  However, under the presentation 
  583.  manager, you must not allow window or dialog procedures to become 
  584.  non-dispatchable. If you do so, the user's PC becomes locked up until the 
  585.  block is relieved. (This is basic to the PM event driven message processing 
  586.  model.)  Therefore, you must create asynchronous tasks (threads) to accomplish 
  587.  the dirty work.  If you want to display a message to the user that describes 
  588.  the thread activity, as in the case of this panel, you may do so by developing 
  589.  an association between the thread and a modeless dialog. 
  590.  
  591.  
  592. ΓòÉΓòÉΓòÉ 8.1. Connect Thread ΓòÉΓòÉΓòÉ
  593.  
  594. The Connect check box is marked to indicate that the server process has issued 
  595. a DosConnectNmPipe to wait for a client process to open its end of the pipe. 
  596.  
  597.  
  598. ΓòÉΓòÉΓòÉ 8.2. Wait Thread ΓòÉΓòÉΓòÉ
  599.  
  600. The Wait Pipe Instance check box is marked to indicate that the client has 
  601. issued a DosWaitNmPipe to wait for an available and connected server pipe 
  602. instance. 
  603.  
  604.  
  605. ΓòÉΓòÉΓòÉ 8.3. Read Thread ΓòÉΓòÉΓòÉ
  606.  
  607. The Read check box is marked to indicate that the client or server process has 
  608. issued a DosRead in order to wait for a message to be written to the other end 
  609. of the pipe. 
  610.  
  611.  
  612. ΓòÉΓòÉΓòÉ 8.4. Write Thread ΓòÉΓòÉΓòÉ
  613.  
  614. The Write check box is marked to indicate that the client or server process has 
  615. issued a DosWrite in order to place a message into the pipe.  This process has 
  616. the potential to block, but normally completes imediately. 
  617.  
  618.  
  619. ΓòÉΓòÉΓòÉ 9. Pipe State Panel ΓòÉΓòÉΓòÉ
  620.  
  621. The Pipe State panel displays the results of a call to DosQNmPHandState. 
  622.  
  623. Fields on this panel are: 
  624.  
  625.  o Blocking 
  626.  o Mode 
  627.  o Type 
  628.  o Readmode 
  629.  o Instance 
  630.  
  631.  
  632. ΓòÉΓòÉΓòÉ 9.1. Blocking ΓòÉΓòÉΓòÉ
  633.  
  634. If blocking is enabled (ON), certain pipe operations will suspend the caller 
  635. until the operation is executable.  For example, if a server process calls 
  636. DosMakeNmPipe, it will be suspended until a client calls DosOpen for the pipe 
  637. instance. 
  638.  
  639. If blocking is disabled (OFF), pipe operation calls will return immediately if 
  640. they are not executable. 
  641.  
  642. This demo has enabled blocking.  Since it is an OS2/PM application, it uses 
  643. asynchronous threads to call functions that may block.  In that way, the 
  644. dialog and window message processing routines are always responsive to the 
  645. user. 
  646.  
  647.  
  648. ΓòÉΓòÉΓòÉ 9.2. Mode ΓòÉΓòÉΓòÉ
  649.  
  650. Named pipes connect TWO processes, a client and a server.  DosQPHandState 
  651. indicates which mode is associated with the handle. 
  652.  
  653.  
  654. ΓòÉΓòÉΓòÉ 9.3. Type ΓòÉΓòÉΓòÉ
  655.  
  656. Named pipes may be defined so that they may be written to a BYTE at a time or a 
  657. record (MESSAGE) at a time. 
  658.  
  659. This demo has enabled message writes. 
  660.  
  661.  
  662. ΓòÉΓòÉΓòÉ 9.4. Readmode ΓòÉΓòÉΓòÉ
  663.  
  664. Named pipes may be set to provide data to DosRead a BYTE at a time or a record 
  665. (MESSAGE) at a time. 
  666.  
  667. The server end is set to byte or message during DosMakeNmPipe processing. 
  668.  
  669. The client opens the pipe using DosOpen.  There is no way to specify byte or 
  670. message reads with this call.  The pipe defaults to byte read mode.  If the 
  671. client wishes message read mode, it must issue the DosSetNmPHandState call to 
  672. set the pipe to read mode. 
  673.  
  674. This demo enables message reads. 
  675.  
  676.  
  677. ΓòÉΓòÉΓòÉ 9.5. Instance ΓòÉΓòÉΓòÉ
  678.  
  679. When a server calls DosMakeNmPipe, it specifies the maximum number of 
  680. occurrences (instances) of a pipe with that name.  The maxinstance 
  681. specification is ignored for all subsequent calls to DosMakeNmPipe.  A server 
  682. may make as many named pipes with the same name as is allowed by the 
  683. maxinstance parameter on the first call. This is an obvious limit to the number 
  684. of concurrent client/server connections available to a named pipe. 
  685.  
  686. This demo uses a special case of the maxinstance parameter.  A value of -1 may 
  687. be specified to provide unlimited named pipe occurrences. 
  688.  
  689. Do not be confused by this instance concept.  Every time a call is made to 
  690. DosMakeNmPipe, a unique handle is returned to represent a pipe instance.  A 
  691. named pipe instance may only connect ONE server process to ONE client process. 
  692. There are NO MANY TO ONE relationships available with a named pipe. 
  693.  
  694.  
  695. ΓòÉΓòÉΓòÉ 10. Pipe Info Panel ΓòÉΓòÉΓòÉ
  696.  
  697. The Pipe Info panel displays the results of a call to DosQNmPipeInfo. 
  698.  
  699. Presented information fields are: 
  700.  
  701.  o Buffersize 
  702.  o Instances 
  703.  o Name 
  704.  
  705.  
  706. ΓòÉΓòÉΓòÉ 10.1. Buffersize ΓòÉΓòÉΓòÉ
  707.  
  708. When a server creates a named pipe instance using DosMakeNmPipe, it must 
  709. specify the size of the pipe's input and output buffers.  The buffersize limits 
  710. the size of the largest message and the number of messages smaller than 
  711. buffersize that may be queued in the pipe. 
  712.  
  713. This demo creates pipes with an input and output buffersize of 512. 
  714.  
  715.  
  716. ΓòÉΓòÉΓòÉ 10.2. Instances ΓòÉΓòÉΓòÉ
  717.  
  718. When a server creates a named pipe instance using DosMakeNmPipe, it must 
  719. specify the maximum number of concurrent instances of a pipe with that name. 
  720. (See  instance field of panel Pipe State.) 
  721.  
  722. DosQNmPipeInfo returns both the instance number of the current pipe handle and 
  723. the max instance specified when the first named pipe instance was created. 
  724.  
  725. This demo uses a special case of the maxinstance parameter.  A value of -1 may 
  726. be specified to provide unlimited named pipe occurrences. 
  727.  
  728.  
  729. ΓòÉΓòÉΓòÉ 10.3. Name ΓòÉΓòÉΓòÉ
  730.  
  731. DosQNmPipeInfo returns the length of the ASCII string for the name of the 
  732. current pipe handle.  It also returns the actual string if the structure 
  733. provided by the caller is large enough to store it. 
  734.  
  735. This information is of dubious value since the caller must have already made or 
  736. opened the named pipe (by name of course) BEFORE it can successfully call 
  737. DosQNmPipeInfo with a valid handle. 
  738.  
  739.  
  740. ΓòÉΓòÉΓòÉ 11. Pipe Peek Panel ΓòÉΓòÉΓòÉ
  741.  
  742. The Pipe Peek panel displays the information returned by a call to 
  743. DosPeekNmPipe. 
  744.  
  745. Fields displayed are: 
  746.  
  747.  o Bytes Buffered 
  748.  o Pipe State 
  749.  
  750.  A feature of Peek that is not shown by this demo, is the ability for the 
  751.  caller to retrieve all or part of the next message in the input buffer without 
  752.  removing any data from the buffer. 
  753.  
  754.  
  755. ΓòÉΓòÉΓòÉ 11.1. Bytes Buffered ΓòÉΓòÉΓòÉ
  756.  
  757. A DosPeekNmPipe call returns two length related integers.  The first count is 
  758. of the total number of bytes in the pipe input buffer.  This count includes the 
  759. two length bytes contained in each message.  The second count is of the length 
  760. of the next message to be read from the buffer.  This count DOES NOT include 
  761. the two bytes contain the length of that message. 
  762.  
  763.  
  764. ΓòÉΓòÉΓòÉ 11.2. Pipe State ΓòÉΓòÉΓòÉ
  765.  
  766. DosPeekNmPipe returns an indicator of the current state of the pipe.  A named 
  767. pipe may be in one of four states: 
  768.  
  769.  o A pipe is DISCONNECTED just after a server has made it, but BEFORE the 
  770.    server issue a DosConnectNmPipe.  Additionally, a pipe may be disconnected 
  771.    specifically by a server process that issues a DosDisConnectNmPipe. 
  772.  o A pipe is LISTENING after a server issues a DosConnectNmPipe, but BEFORE a 
  773.    client issues a DosOpen for the pipe. 
  774.  o A pipe is CONNECTED after the client issues a DosOpen for the pipe. 
  775.  o A pipe is CLOSING after either the client or server issues a DosClose for 
  776.    the pipe. 
  777.  
  778.  
  779. ΓòÉΓòÉΓòÉ 12. Help for Key Assignments ΓòÉΓòÉΓòÉ
  780.  
  781. The list of keys is arranged in groups. 
  782.  
  783. ACCELERATOR KEYS 
  784.  
  785.  Ctrl+c 
  786.       Perform Client Pipe Functions 
  787.  
  788.  Ctrl+s 
  789.       Perform Server Pipe Functions 
  790.  
  791.  Ctrl+l 
  792.       Create another Pipes Demo Window (Clone) 
  793.  
  794.  Ctrl+t 
  795.       Execute DosQNmPHandState for the pipe 
  796.  
  797.  Ctrl+i 
  798.       Execute DosQNmPipeInfo for the pipe 
  799.  
  800.  Ctrl+p 
  801.       Execute DosPeekNmPipe for the pipe 
  802.  
  803.  F3 
  804.       Exit program 
  805.  
  806.  HELP KEYS 
  807.  
  808.  F1 
  809.       Get help 
  810.  
  811.  F2 
  812.       Get extended help (from within any help window) 
  813.  
  814.  Alt+F4 
  815.       End help 
  816.  
  817.  F9 
  818.       Go to a list of keys (from within any help window) 
  819.  
  820.  F11 
  821.       Go to the help index (from within any help window) 
  822.  
  823.  Esc 
  824.       Previous Help Panel, or End help if only one panel 
  825.  
  826.  Alt+F6 
  827.       Go to/from help and programs 
  828.  
  829.  Shift+F10 
  830.       Get help for help 
  831.  
  832.  SYSTEM KEYS 
  833.  
  834.  Alt+F6 
  835.       Switch to the next windowed program 
  836.  
  837.  Alt+Esc 
  838.       Switch to the next program, including full-screen programs 
  839.  
  840.  Ctrl+Esc 
  841.       Switch to the Task List 
  842.  
  843.  WINDOW KEYS 
  844.  
  845.  F3 
  846.       Close a window 
  847.  
  848.  F10 
  849.       Go to/from the action bar 
  850.  
  851.  Arrow keys 
  852.       Move among choices 
  853.  
  854.  End 
  855.       Go to the last choice in a pull-down 
  856.  
  857.  Esc 
  858.       Cancel a pull-down or the system menu 
  859.  
  860.  Home 
  861.       Go to the first choice in a pull-down 
  862.  
  863.  PgUp 
  864.       Scroll the contents of the window up one page 
  865.  
  866.  PgDn 
  867.       Scroll the contents of the window down one page 
  868.  
  869.  Underlined letter 
  870.       Move among the choices on the action bar and pull-downs 
  871.  
  872.  Alt+F10 
  873.       Go to/from the action bar 
  874.  
  875.  Alt+F4 or F3 
  876.       Close the window 
  877.  
  878.  Alt+F5 
  879.       Restore the window 
  880.  
  881.  Alt+F7 
  882.       Move the window 
  883.  
  884.  Alt+F8 
  885.       Size the window 
  886.  
  887.  Alt+F9 
  888.       Minimize the window 
  889.  
  890.  Alt+F10 
  891.       Maximize the window 
  892.  
  893.  Ctrl+PgDn or Shift+F8 
  894.       Scroll the contents of the window right one page 
  895.  
  896.  Ctrl+PgUp or Shift+F7 
  897.       Scroll the contents of the window left one page 
  898.  
  899.  Shift+Esc or Alt+Spacebar 
  900.       Go to/from the system menu 
  901.  
  902.  Shift+Esc or Alt 
  903.       Go to/from the system menu of a text window 
  904.