'p1, pipe "server", execute this first then p2.bas 
'option explicit 
#include once "windows.bi" 

dim as HANDLE ph,cf 
dim as string pn,pout 
dim pin as string * 128 
dim as integer res,werr,pcount,dwmode 

dim as  SECURITY_ATTRIBUTES  sa
dim as  PSECURITY_DESCRIPTOR pSD

pSD = Allocate(SECURITY_DESCRIPTOR_MIN_LENGTH)
InitializeSecurityDescriptor(pSD, SECURITY_DESCRIPTOR_REVISION)
SetSecurityDescriptorDacl(pSD, TRUE, NULL, FALSE)
sa.nLength = sizeof(sa)
sa.lpSecurityDescriptor = pSD
sa.bInheritHandle = TRUE

pn="\\.\PIPE\tpipe" 
ph=CreateNamedPipe(strptr(pn),_ 
    PIPE_ACCESS_INBOUND,_ 
    PIPE_TYPE_MESSAGE or PIPE_READMODE_MESSAGE or PIPE_WAIT,_ 
    10,_ 
    128,_ 
    128,_ 
    200,_ 
    @sa)

print "PipeHandle: ";"Handle: ";hex(ph)
if ph = INVALID_HANDLE_VALUE then
  werr=GetLastError() '2 file not found 
  print "ERR: ";werr 
  end
end if

print "Waiting for connection..."
res=ConnectNamedPipe(ph,NULL) 
if res = 0 then
  werr=GetLastError() '2 file not found 
  print "ERR: ";werr
  end
end if
print " Connected: ";res

res=ReadFile(ph,_ 
    @pin,_ 
    128,_ 
    @pcount,_ 
    NULL) 

print "  ReadFile: ";res
if res = 0 then
  werr=getlasterror() '6 invalid handle, obviously 
  print "ERR: ";werr 
  end 
end if

print pin
sleep
 Deallocate pSD