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

CreateFile() call fails with error code 2: "The system cannot find the file specified".

4,759 views
Skip to first unread message

PaulH

unread,
Dec 16, 2008, 11:05:09 AM12/16/08
to
I have a Named Pipe server running where the pipe is created with the
following flags:
CreateNamedPipe( _T( "\\\\192.168.1.2\\pipe\\MyPipeName" )
PIPE_ACCESS_DUPLEX,
PIPE_TYPE_MESSAGE |
PIPE_READMODE_MESSAGE |
PIPE_WAIT,
PIPE_UNLIMITED_INSTANCES,
4096,
4096,
0,
NULL )

I would like to connect to that pipe from another PC. To do that, I'm
using CreateFile() like this:
m_hPipe = ::CreateFile( _T( "\\\\192.168.1.2\\pipe\\MyPipeName" ),
GENERIC_READ | GENERIC_WRITE,
0,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
NULL )

For now, I'm testing with both the client and server on the same PC,
but still specifying the IP address of one of the network cards as
shown above. Unfortunately, the CreateFile() call fails with error
code 2: "The system cannot find the file specified". If, instead of
the IP address, I use a ".", everything works correctly.

I'm using Windows XP SP3 with MSVS2008. My windows firewall is
disabled.

What can I do to get the pipe to connect across a network connection?

Thanks,
PaulH

PaulH

unread,
Dec 16, 2008, 11:46:04 AM12/16/08
to

EDIT: The PC I'm running this on has two NICs. If I disable the NIC
that this server will not use, I get a different error code: 1265 -
"The system detected a possible attempt to compromise security. Please
ensure that you can contact the server that authenticated you."

Christoph Lindemann

unread,
Dec 17, 2008, 3:28:23 AM12/17/08
to
You are specifying "FILE_ATTRIBUTE_NORMAL" in your client CreateFile call.
Try using 0 for default attributes. FILE_ATTRIBUTE_NORMAL is "...used only
for file objects, not other types of objects that CreateFile creates." Check
out the examples and the CreateNamedPipe and CreateFile topics in the
Windows SDK (especially "Remarks" sections).

Also, make sure to provide correct SecurityAttributes if you want to connect
to the pipe from other processes and machines.

--
Christoph Lindemann


"PaulH" <paul...@gmail.com> wrote in message
news:3c7ca2d1-ab0d-413e...@o40g2000prn.googlegroups.com...

PaulH

unread,
Dec 17, 2008, 10:48:03 AM12/17/08
to
On Dec 17, 2:28 am, "Christoph Lindemann"

<clindema...@newsgroups.nospam> wrote:
> You are specifying "FILE_ATTRIBUTE_NORMAL" in your client CreateFile call.
> Try using 0 for default attributes. FILE_ATTRIBUTE_NORMAL is "...used only
> for file objects, not other types of objects that CreateFile creates." Check
> out the examples and the CreateNamedPipe and CreateFile topics in the
> Windows SDK (especially "Remarks" sections).
>
> Also, make sure to provide correct SecurityAttributes if you want to connect
> to the pipe from other processes and machines.
>
> --
> Christoph Lindemann
>
> "PaulH" <paul.h...@gmail.com> wrote in message

It was the security attribute structure that fixed it. I had to create
a DACL. (I also fixed the file attribute, though.)

Thanks for your help!

-PaulH

0 new messages