PipeServerCreate

Creates an instance of a named pipe and waits for a client to connect. (Windows NT family only)

Syntax:

PipeServerCreate(pipe-name, timeout)

Parameters:

(s) pipe-name specifies the name of a pipe, in the form: \\.\pipe\PipeName

(i) timeout specifies the timeout period in seconds that it will wait for a client to connect, or -1 for no timeout.

Returns:

(i/s) pipe-handle returns a pipe handle on success, or "*TIMER*".

 

A maximum of 100 instances of a pipe can be created.

Note: The pipe server cannot create a pipe on another computer, so PipeServerCreate must use a period for the server name, as shown in the following example.

\\.\pipe\PipeName

 

Example:


;------------
; CLIENT.WBT
;------------
SERVER = "myserver" ; Or "." for the local machine
pipename = "fluggle"
pipepath = StrCat("\\",SERVER,"\pipe\",pipename)
querydata = "GET_TIME"
timeout = -1
IntControl(12,5,0,0,0);terminate quietly
notice = StrCat(@CRLF,@CRLF,"[ Press CTRL+BREAK to exit script ]")
BoxOpen("Time Client","Initializing connection to server...")
While @TRUE
   pipehandle = PipeClientOpen(pipepath,timeout)
   If pipehandle=="*ERROR*" || pipehandle=="*TIMER*" Then Continue ; try again
   data=PipeClientSendRecvData(pipehandle, querydata,timeout)
   BoxText(StrCat("Data sent from server = ", data, notice))
   PipeClientClose(pipehandle)
EndWhile
Message("Client","Exited")
Exit
;------------
; SERVER.WBT
;------------
pipename="\\.\pipe\fluggle"
timeout = -1
IntControl(12,5,0,0,0);terminate quietly
notice = StrCat(@CRLF,@CRLF,"[ Press CTRL+BREAK to exit script ]")
BoxOpen("Time Server","Initializing - Awaiting connect from Client")
While @TRUE ; General Server loop
   pipehandle = PipeServerCreate(pipename,timeout)
   If pipehandle=="*ERROR*" || pipehandle=="*TIMER*" Then Continue
   readinfo = PipeServerRead(pipehandle, timeout)
   If readinfo=="*ERROR*" || readinfo=="*TIMER*"
      PipeServerClose(pipehandle,0)
      Continue ; try again
   EndIf
   If readinfo == "GET_TIME"
      response= TimeYmdHms()
   Else
      response = "ERROR: UNKNOWN REQUEST"
   EndIf
   rslt=PipeServerWrite(pipehandle,response)
   BoxText(StrCat("Data sent to client = ",response, notice))
   PipeServerClose(pipehandle,timeout)
EndWhile
Message("Server","Exited")
Exit
See Also:

PipeClientClose, PipeClientOpen, PipeClientSendRecvData, PipeInfo, PipeServerClose, PipeServerRead, PipeServerWrite