Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Help w/ named pipes between NT and WFG

0 views
Skip to first unread message

Ed Heinrich - The LOKI Group, Inc.

unread,
Apr 7, 1995, 3:00:00 AM4/7/95
to
I am having a problem attempting to run a 16 bit program, compiled and
linked under Visual C 1.5 on a NT system, on a Windows For Workgroups
system. The program, which works fine when run on the same machine
booted into NT, uses a named pipe, across a network, to pass messages
back and forth to another NT machine. When run on WFG, the _lopen
call fails with a descriptive -1 status code.

From what I can tell, the WFG and NT machines are set up correctly as I
can successfully run the SQL Client utilities on the WFG machine, using
named pipes, to interact with the SQLServer running on the NT machine.

Node LOKI, a NT Advanced Server 3.5 system creates the named pipe with
the following code:

#define PIPE_TIMEOUT 60000 // 60 seconds
#define PCLD_BUFFER 8192 // Maximum size of pipe packets

_TCHAR pipeName [] = _TEXT ("\\\\.\\pipe\\LOKI_TP_Pipe");

//
// Allocate memory for the security descriptor.
//
pSD = (PSECURITY_DESCRIPTOR) LocalAlloc(LPTR,
SECURITY_DESCRIPTOR_MIN_LENGTH);
//
// Initialize the new security descriptor.
//
InitializeSecurityDescriptor (pSD, SECURITY_DESCRIPTOR_REVISION);
//
// Add a NULL descriptor ACL to the security descriptor.
//
SetSecurityDescriptorDacl(pSD, TRUE, (PACL) NULL, FALSE);
sa.nLength = sizeof(sa);
sa.lpSecurityDescriptor = pSD;
sa.bInheritHandle = TRUE;
//
// Main dispatching loop.
//
for (;;) // Ever
{
//
// Create an instance of the named pipe & wait until a client connects to it.
//
if ((hPipeHandle = CreateNamedPipe (
pipeName, // Name of da pipe
PIPE_ACCESS_DUPLEX // Allow read/write access
| FILE_FLAG_OVERLAPPED, // Overlapped I/O permitted
PIPE_TYPE_MESSAGE // Message oriented pipe
| PIPE_READMODE_MESSAGE
| PIPE_WAIT, // Blocking mode
PIPE_UNLIMITED_INSTANCES,
// Maxiumum instances
PCLD_BUFFER, // Output buffer size
PCLD_BUFFER, // Input buffer size
PIPE_TIMEOUT, // Timeout value
&sa)) == INVALID_HANDLE_VALUE)
// No security attributes
exit (GetLastError () );
//
// Wait for the client to connect.
//
connected = ConnectNamedPipe (hPipeHandle, NULL) ? TRUE :
(GetLastError () == ERROR_PIPE_CONNECTED);
//
// If client failed to connect to pipe, close the handle and go wait
// on another connection attempt.
//
if (!connected) // Weird pipe or client behavior?
continue; // ... wait for another attempt

On node BALDER, the 16 bit client code use the following:


char LTPSPipeName [] = {"\\\\loki\\pipe\\LOKI_TP_Pipe"};

if ((hPipe = OpenPipe (LTPSPipeName)) != (HANDLE)NULL)
{
....
}

HANDLE OpenPipe (char *pName)

{

HANDLE hHandle; // Local handle storage

while (1)
{
hHandle = _lopen(pName, READ_WRITE);
if
(hHandle == HFILE_ERROR)
return (HANDLE) NULL;
else
break;
//
// No instance of pipe is available, wait 10 seconds for one.
//
if (!DosWaitNmPipe(pName, 10000))
return (FALSE);
} // While (1) loop

//
// We have a pipe - set read mode to MESSAGE
//
if (DosSetNmPHandState(hHandle, NP_READMODE_MESSAGE))
{
_lclose(hHandle); // To avoid dangling pipes...
return((HANDLE)NULL);
}

return hHandle; // To caller
}

If I boot BALDER into NT, and run the same 16-bit image, it works fine.
I am sure there is something I'm doing that is incorrect, but after I
spent several hours searching the Developer's CD to no avail, I would
greatly appreciate any insight someone reading this list might provide.

*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*
Ed Heinrich " In another life, You're always the hero
The LOKI Group, Inc. In another life, You always win the game
Park City, UT Office In another life, No one ever cheats you
HEIN...@byu.EDU In another life, You never have to change"

Vernon Reid __Living Colour__
*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*

Paul Vincent Craven

unread,
Apr 10, 1995, 3:00:00 AM4/10/95
to
hein...@yvax.byu.edu (Ed Heinrich - The LOKI Group, Inc.) wrote:

>I am having a problem attempting to run a 16 bit program, compiled and
>linked under Visual C 1.5 on a NT system, on a Windows For Workgroups
>system. The program, which works fine when run on the same machine
>booted into NT, uses a named pipe, across a network, to pass messages
>back and forth to another NT machine. When run on WFG, the _lopen
>call fails with a descriptive -1 status code.

You do know that you can not create a pipe on a WFW machine? You can
only open it as a client.


John Kepus

unread,
Apr 11, 1995, 3:00:00 AM4/11/95
to
>/ hpcc01:comp.os.ms-windows.programmer.win32 / cra...@umr.edu (Paul Vincent Craven) / 6:43 am Apr 10, 1995 /
>----------

Not only that, using the *same* Win32 API as NT, Windows 95 *can't* create
a named pipe.

It can open one, however, the same as the *16-bit* WFW.

Hmmm... seems 95 is the same old... nah!

-Todd K.

:)


Oleg E. Tsvinev

unread,
Apr 16, 1995, 3:00:00 AM4/16/95
to
tke...@hpcc01.corp.hp.com (John Kepus) wrote:

// >/ hpcc01:comp.os.ms-windows.programmer.win32 / cra...@umr.edu (Paul Vincent Craven) / 6:43 am Apr 10, 1995 /
// >hein...@yvax.byu.edu (Ed Heinrich - The LOKI Group, Inc.) wrote:
// >
// >>I am having a problem attempting to run a 16 bit program, compiled and
// >>linked under Visual C 1.5 on a NT system, on a Windows For Workgroups
// >>system. The program, which works fine when run on the same machine
// >>booted into NT, uses a named pipe, across a network, to pass messages
// >>back and forth to another NT machine. When run on WFG, the _lopen
// >>call fails with a descriptive -1 status code.
// >
// >You do know that you can not create a pipe on a WFW machine? You can
// >only open it as a client.
// >
// >----------

// Not only that, using the *same* Win32 API as NT, Windows 95 *can't* create
// a named pipe.

// It can open one, however, the same as the *16-bit* WFW.

// Hmmm... seems 95 is the same old... nah!

No, no! They (MS) say they have no time to implement it in 1st
version. Anyway it's a part of Win32 API.

0 new messages