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

ERROR_PIPE_BUSY - All pipe instances are busy

258 views
Skip to first unread message

Manoj Jangid

unread,
Nov 11, 2009, 2:18:42 AM11/11/09
to
When I call CreateFile() second time I am getting error massege 231
[ERROR_PIPE_BUSY - All pipe instances are busy]

I am sending message from service application to client application.
Named pipe is create in service application and client application is
receving data from service application.

Service Application Functions
bool InitServer()
{
...
m_hServer = ::CreateNamedPipe(m_strPipeName,
PIPE_ACCESS_OUTBOUND,
PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT,
PIPE_UNLIMITED_INSTANCES,
sizeof maxSize,
sizeof maxSize,
NMPWAIT_USE_DEFAULT_WAIT,
&sa);

...
...
}

Client Application


bool InitClient()
{
DWORD dwError = 0;
while (true)
{
m_hClient = ::CreateFile( m_strPipeName,
GENERIC_READ,
0,
0,
OPEN_EXISTING,
0,
0);
if (m_hClient != INVALID_HANDLE_VALUE)
{
break;
}
if (GetLastError() != ERROR_PIPE_BUSY)
{
return false;
}
if (!WaitNamedPipe(m_strPipeName, 10000))
{
return false;
}
}
return true;
}

Above client code working when I am connecting first time.
After restart client application I am getting above mentioned error.

WaitNamedPipe - this gives [Error Number - 121 The semaphore timeout
period has expired]

I close the handle properly when client disconnect.

any clue to solve this?

-Manoj

Goran

unread,
Nov 11, 2009, 4:15:54 AM11/11/09
to
Hi!

It simply looks like you did not make your server wait on a client
connection through ConnectNamedPipe. Without a call to
ConnectNamedPipe in the server, I would be surprised that you can
connect your client even once, but it's a long time since I touched
pipes, so I could be wrong.

That said, if this is not "learning" code, is there a reason for use
of pipes? There are easier and more powerful ways to do IPC.

Goran.

Manoj Jangid

unread,
Nov 11, 2009, 4:42:40 AM11/11/09
to

Thank you Goran,

Sorry I didn't paste ConnectNamedPipe code, ConnectNamedPipe is there.
what are the other ways to do IPC?

-Manoj

Goran

unread,
Nov 11, 2009, 5:22:07 AM11/11/09
to
On Nov 11, 10:42 am, Manoj Jangid <manoj.jan...@gmail.com> wrote:
> Sorry I didn't paste ConnectNamedPipe code, ConnectNamedPipe is there.

I am speaking off the top of my head here... With pipes, operation
is:

ConnectNamedPipe on the server.
CreateFile on the client
communication
CloseHandle on the client
DisonnectNamedPipe on the server

I seem to remember that you get ERROR_PIPE_BUSY if server did not call
DisconnectNamedPipe for a previous connection, or if there really is
no pending ConnectNamedPipe.

Also, you might get better answers on some microsoft.public.win32
group.

Goran.

0 new messages