NamedPipeClientStream.Write not returning
I'm trying to develop two applications which, while running, communicate to each other through named pipes, the server application create two pipes, one to send data to clients, the other to receive data from it.
Writing and reading operations are handled in another thread by using a Task, there are no problems while creating the pipes or connecting to them.
There is a problem when the client attempts to write data in the pipe, once the Write method is called, the execution just stops.
//Server code
//NamedPipesManager is a class created by me.
while (!TasksStopper.IsCancellationRequested)
{
if (!NamedPipesManager.IsConnected(OutPipe) & !NamedPipesManager.IsConnected(InPipe))
{
OutPipe.WaitForConnection();
InPipe.WaitForConnection();
}
CanReceiveMessages.WaitOne(); //The server start reading data only when signaled by the client, so that there is always data to read.
MessagesSemaphore.WaitOne(); //The methods of the class can be run only by one thread at a time, a Semaphore is used to regulate access.
NamedPipesManager.ReceiveMessage(InPipe, out MessageReceived.MessageType, out MessageReceived.Response);
if (MessageReceived.MessageType == NamedPipesManager.MESSAGES.CUSTOM_PROJECT_PATH_REQUEST)
{
MessagesSemaphore.WaitOne();
NamedPipesManager.SendMessage(OutPipe, NamedPipesManager.MESSAGES.CUSTOM_PROJECT_PATH_REQUEST, Convert.ToString(CustomProjectsPath));
}
else if (MessageReceived.MessageType == NamedPipesManager.MESSAGES.DEFAULT_PROJECTS_PATH_REQUEST)
{
MessagesSemaphore.WaitOne();
NamedPipesManager.SendMessage(OutPipe, NamedPipesManager.MESSAGES.DEFAULT_PROJECTS_PATH_REQUEST, DefaultProjectsPath);
}
}
if (NamedPipesManager.IsConnected(OutPipe))
{
MessagesSemaphore.WaitOne();
NamedPipesManager.SendMessage(OutPipe, NamedPipesManager.MESSAGES.DISCONNECT, null);
OutPipe.WaitForPipeDrain();
}
//Client code
NamedPipeClientStream HubInPipe = null;
NamedPipeClientStream HubOutPipe = null;
while (!TasksStopper.IsCancellationRequested)
{
HubInPipe = NamedPipesManager.ConnectToNamedPipe(null, "ProjectExchangeAppOutPipe", NamedPipesManager.PIPE_DIRECTION.IN);
HubInPipe.ReadMode = PipeTransmissionMode.Message;
HubOutPipe = NamedPipesManager.ConnectToNamedPipe(null, "ProjectExchangeAppInPipe", NamedPipesManager.PIPE_DIRECTION.OUT);
HubOutPipe.ReadMode = PipeTransmissionMode.Message;
PipesConnectedEvent.Set();
SendMessageEvent.WaitOne();
MessagesSemaphore.WaitOne();
NamedPipesManager.SendMessage(HubOutPipe, MessageType, MessageToSend);
HubWaitHandle.Set();
MessagesSemaphore.WaitOne();
NamedPipesManager.ReceiveMessage(HubInPipe, out ReceivedMessage.MessageType, out ReceivedMessage.Response);
if (ReceivedMessage.MessageType == NamedPipesManager.MESSAGES.CUSTOM_PROJECT_PATH_REQUEST || ReceivedMessage.MessageType == NamedPipesManager.MESSAGES.DEFAULT_PROJECTS_PATH_REQUEST)
{
ReceivedMessages.Add(ReceivedMessage);
MessageReceivedEvent.Set();
}
else if (ReceivedMessage.MessageType == NamedPipesManager.MESSAGES.SETTINGS_PROFILE_CHANGED)
{
DialogResult result = MessageBox.Show("...", "Avviso", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
if (result == DialogResult.Yes)
{
ProfileName = ReceivedMessage.Response;
}
}
else if (ReceivedMessage.MessageType == NamedPipesManager.MESSAGES.DISCONNECT)
{
NamedPipesManager.ClosePipe(HubInPipe);
NamedPipesManager.ClosePipe(HubOutPipe);
}
}
if (NamedPipesManager.IsConnected(HubInPipe) & NamedPipesManager.IsConnected(HubOutPipe))
{
NamedPipesManager.ClosePipe(HubInPipe);
NamedPipesManager.ClosePipe(HubOutPipe);
}
else if (NamedPipesManager.IsConnected(HubInPipe) & !NamedPipesManager.IsConnected(HubOutPipe))
{
NamedPipesManager.ClosePipe(HubInPipe);
}
else if (!NamedPipesManager.IsConnected(HubInPipe) & NamedPipesManager.IsConnected(HubOutPipe))
{
NamedPipesManager.ClosePipe(HubOutPipe);
}
//SendMessage method of NamedPipesManager class.
if (Message != null)
{
byte Buffer = Encoding.Default.GetBytes(MessageType.ToString("D") + " " + Message);
Pipe.Write(Buffer, 0, Buffer.Length); //L'esecuzione si blocca qui.
}
else
{
byte Buffer = Encoding.Default.GetBytes(MessageType.ToString("D"));
Pipe.Write(Buffer, 0, Buffer.Length); //L'esecuzione si blocca qui.
}
Semaphore.Release();
//ReceiveMessage method of NamedPipesManager class
MessageType = MESSAGES.NONE;
Message = null;
System.Diagnostics.Debugger.Break();
StringBuilder sb = new StringBuilder();
byte Buffer = new byte[10];
string Chunk = string.Empty;
while (Pipe.IsConnected)
{
int BytesRead = Pipe.Read(Buffer, 0, Buffer.Length);
do
{
Chunk = Encoding.Default.GetString(Buffer);
sb.Append(Chunk);
Buffer = new byte[10];
}
while (!Pipe.IsMessageComplete);
string MessageReceived = sb.ToString();
MessageType = (MESSAGES)Convert.ToInt32(MessageReceived[0].ToString());
if (MessageReceived.Length > 1)
{
Message = MessageReceived.Substring(3);
}
}
Semaphore.Release();
c# .net winforms named-pipes
add a comment |
I'm trying to develop two applications which, while running, communicate to each other through named pipes, the server application create two pipes, one to send data to clients, the other to receive data from it.
Writing and reading operations are handled in another thread by using a Task, there are no problems while creating the pipes or connecting to them.
There is a problem when the client attempts to write data in the pipe, once the Write method is called, the execution just stops.
//Server code
//NamedPipesManager is a class created by me.
while (!TasksStopper.IsCancellationRequested)
{
if (!NamedPipesManager.IsConnected(OutPipe) & !NamedPipesManager.IsConnected(InPipe))
{
OutPipe.WaitForConnection();
InPipe.WaitForConnection();
}
CanReceiveMessages.WaitOne(); //The server start reading data only when signaled by the client, so that there is always data to read.
MessagesSemaphore.WaitOne(); //The methods of the class can be run only by one thread at a time, a Semaphore is used to regulate access.
NamedPipesManager.ReceiveMessage(InPipe, out MessageReceived.MessageType, out MessageReceived.Response);
if (MessageReceived.MessageType == NamedPipesManager.MESSAGES.CUSTOM_PROJECT_PATH_REQUEST)
{
MessagesSemaphore.WaitOne();
NamedPipesManager.SendMessage(OutPipe, NamedPipesManager.MESSAGES.CUSTOM_PROJECT_PATH_REQUEST, Convert.ToString(CustomProjectsPath));
}
else if (MessageReceived.MessageType == NamedPipesManager.MESSAGES.DEFAULT_PROJECTS_PATH_REQUEST)
{
MessagesSemaphore.WaitOne();
NamedPipesManager.SendMessage(OutPipe, NamedPipesManager.MESSAGES.DEFAULT_PROJECTS_PATH_REQUEST, DefaultProjectsPath);
}
}
if (NamedPipesManager.IsConnected(OutPipe))
{
MessagesSemaphore.WaitOne();
NamedPipesManager.SendMessage(OutPipe, NamedPipesManager.MESSAGES.DISCONNECT, null);
OutPipe.WaitForPipeDrain();
}
//Client code
NamedPipeClientStream HubInPipe = null;
NamedPipeClientStream HubOutPipe = null;
while (!TasksStopper.IsCancellationRequested)
{
HubInPipe = NamedPipesManager.ConnectToNamedPipe(null, "ProjectExchangeAppOutPipe", NamedPipesManager.PIPE_DIRECTION.IN);
HubInPipe.ReadMode = PipeTransmissionMode.Message;
HubOutPipe = NamedPipesManager.ConnectToNamedPipe(null, "ProjectExchangeAppInPipe", NamedPipesManager.PIPE_DIRECTION.OUT);
HubOutPipe.ReadMode = PipeTransmissionMode.Message;
PipesConnectedEvent.Set();
SendMessageEvent.WaitOne();
MessagesSemaphore.WaitOne();
NamedPipesManager.SendMessage(HubOutPipe, MessageType, MessageToSend);
HubWaitHandle.Set();
MessagesSemaphore.WaitOne();
NamedPipesManager.ReceiveMessage(HubInPipe, out ReceivedMessage.MessageType, out ReceivedMessage.Response);
if (ReceivedMessage.MessageType == NamedPipesManager.MESSAGES.CUSTOM_PROJECT_PATH_REQUEST || ReceivedMessage.MessageType == NamedPipesManager.MESSAGES.DEFAULT_PROJECTS_PATH_REQUEST)
{
ReceivedMessages.Add(ReceivedMessage);
MessageReceivedEvent.Set();
}
else if (ReceivedMessage.MessageType == NamedPipesManager.MESSAGES.SETTINGS_PROFILE_CHANGED)
{
DialogResult result = MessageBox.Show("...", "Avviso", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
if (result == DialogResult.Yes)
{
ProfileName = ReceivedMessage.Response;
}
}
else if (ReceivedMessage.MessageType == NamedPipesManager.MESSAGES.DISCONNECT)
{
NamedPipesManager.ClosePipe(HubInPipe);
NamedPipesManager.ClosePipe(HubOutPipe);
}
}
if (NamedPipesManager.IsConnected(HubInPipe) & NamedPipesManager.IsConnected(HubOutPipe))
{
NamedPipesManager.ClosePipe(HubInPipe);
NamedPipesManager.ClosePipe(HubOutPipe);
}
else if (NamedPipesManager.IsConnected(HubInPipe) & !NamedPipesManager.IsConnected(HubOutPipe))
{
NamedPipesManager.ClosePipe(HubInPipe);
}
else if (!NamedPipesManager.IsConnected(HubInPipe) & NamedPipesManager.IsConnected(HubOutPipe))
{
NamedPipesManager.ClosePipe(HubOutPipe);
}
//SendMessage method of NamedPipesManager class.
if (Message != null)
{
byte Buffer = Encoding.Default.GetBytes(MessageType.ToString("D") + " " + Message);
Pipe.Write(Buffer, 0, Buffer.Length); //L'esecuzione si blocca qui.
}
else
{
byte Buffer = Encoding.Default.GetBytes(MessageType.ToString("D"));
Pipe.Write(Buffer, 0, Buffer.Length); //L'esecuzione si blocca qui.
}
Semaphore.Release();
//ReceiveMessage method of NamedPipesManager class
MessageType = MESSAGES.NONE;
Message = null;
System.Diagnostics.Debugger.Break();
StringBuilder sb = new StringBuilder();
byte Buffer = new byte[10];
string Chunk = string.Empty;
while (Pipe.IsConnected)
{
int BytesRead = Pipe.Read(Buffer, 0, Buffer.Length);
do
{
Chunk = Encoding.Default.GetString(Buffer);
sb.Append(Chunk);
Buffer = new byte[10];
}
while (!Pipe.IsMessageComplete);
string MessageReceived = sb.ToString();
MessageType = (MESSAGES)Convert.ToInt32(MessageReceived[0].ToString());
if (MessageReceived.Length > 1)
{
Message = MessageReceived.Substring(3);
}
}
Semaphore.Release();
c# .net winforms named-pipes
1
Could it be the case that the reading side is not reading? The pipe buffers might be full.
– usr
Nov 14 '18 at 19:05
The server starts to read data only when signaled by the client through a global EventWaitHandle, the client notifies the server only after writing to the pipe but, since the write operation never completes, the notification isn't sent.
– dt_overflow
Nov 14 '18 at 19:41
It seems better to not use an event at all but to make the server continuously read from the pipe. What do you need to event for?
– usr
Nov 14 '18 at 20:09
Without the event the server becomes unresponsive and the call of the client to the Write method still doesn't return.
– dt_overflow
Nov 14 '18 at 23:52
Understand why that happens and fix the bug. The event complicates the solution and makes it not work. Pipe buffers are limited. Both sender and receiver need to take that into account. The receiver must be able to receive partial messages and piece them together. Often, this is done by sending a length prefix.
– usr
Nov 15 '18 at 8:41
add a comment |
I'm trying to develop two applications which, while running, communicate to each other through named pipes, the server application create two pipes, one to send data to clients, the other to receive data from it.
Writing and reading operations are handled in another thread by using a Task, there are no problems while creating the pipes or connecting to them.
There is a problem when the client attempts to write data in the pipe, once the Write method is called, the execution just stops.
//Server code
//NamedPipesManager is a class created by me.
while (!TasksStopper.IsCancellationRequested)
{
if (!NamedPipesManager.IsConnected(OutPipe) & !NamedPipesManager.IsConnected(InPipe))
{
OutPipe.WaitForConnection();
InPipe.WaitForConnection();
}
CanReceiveMessages.WaitOne(); //The server start reading data only when signaled by the client, so that there is always data to read.
MessagesSemaphore.WaitOne(); //The methods of the class can be run only by one thread at a time, a Semaphore is used to regulate access.
NamedPipesManager.ReceiveMessage(InPipe, out MessageReceived.MessageType, out MessageReceived.Response);
if (MessageReceived.MessageType == NamedPipesManager.MESSAGES.CUSTOM_PROJECT_PATH_REQUEST)
{
MessagesSemaphore.WaitOne();
NamedPipesManager.SendMessage(OutPipe, NamedPipesManager.MESSAGES.CUSTOM_PROJECT_PATH_REQUEST, Convert.ToString(CustomProjectsPath));
}
else if (MessageReceived.MessageType == NamedPipesManager.MESSAGES.DEFAULT_PROJECTS_PATH_REQUEST)
{
MessagesSemaphore.WaitOne();
NamedPipesManager.SendMessage(OutPipe, NamedPipesManager.MESSAGES.DEFAULT_PROJECTS_PATH_REQUEST, DefaultProjectsPath);
}
}
if (NamedPipesManager.IsConnected(OutPipe))
{
MessagesSemaphore.WaitOne();
NamedPipesManager.SendMessage(OutPipe, NamedPipesManager.MESSAGES.DISCONNECT, null);
OutPipe.WaitForPipeDrain();
}
//Client code
NamedPipeClientStream HubInPipe = null;
NamedPipeClientStream HubOutPipe = null;
while (!TasksStopper.IsCancellationRequested)
{
HubInPipe = NamedPipesManager.ConnectToNamedPipe(null, "ProjectExchangeAppOutPipe", NamedPipesManager.PIPE_DIRECTION.IN);
HubInPipe.ReadMode = PipeTransmissionMode.Message;
HubOutPipe = NamedPipesManager.ConnectToNamedPipe(null, "ProjectExchangeAppInPipe", NamedPipesManager.PIPE_DIRECTION.OUT);
HubOutPipe.ReadMode = PipeTransmissionMode.Message;
PipesConnectedEvent.Set();
SendMessageEvent.WaitOne();
MessagesSemaphore.WaitOne();
NamedPipesManager.SendMessage(HubOutPipe, MessageType, MessageToSend);
HubWaitHandle.Set();
MessagesSemaphore.WaitOne();
NamedPipesManager.ReceiveMessage(HubInPipe, out ReceivedMessage.MessageType, out ReceivedMessage.Response);
if (ReceivedMessage.MessageType == NamedPipesManager.MESSAGES.CUSTOM_PROJECT_PATH_REQUEST || ReceivedMessage.MessageType == NamedPipesManager.MESSAGES.DEFAULT_PROJECTS_PATH_REQUEST)
{
ReceivedMessages.Add(ReceivedMessage);
MessageReceivedEvent.Set();
}
else if (ReceivedMessage.MessageType == NamedPipesManager.MESSAGES.SETTINGS_PROFILE_CHANGED)
{
DialogResult result = MessageBox.Show("...", "Avviso", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
if (result == DialogResult.Yes)
{
ProfileName = ReceivedMessage.Response;
}
}
else if (ReceivedMessage.MessageType == NamedPipesManager.MESSAGES.DISCONNECT)
{
NamedPipesManager.ClosePipe(HubInPipe);
NamedPipesManager.ClosePipe(HubOutPipe);
}
}
if (NamedPipesManager.IsConnected(HubInPipe) & NamedPipesManager.IsConnected(HubOutPipe))
{
NamedPipesManager.ClosePipe(HubInPipe);
NamedPipesManager.ClosePipe(HubOutPipe);
}
else if (NamedPipesManager.IsConnected(HubInPipe) & !NamedPipesManager.IsConnected(HubOutPipe))
{
NamedPipesManager.ClosePipe(HubInPipe);
}
else if (!NamedPipesManager.IsConnected(HubInPipe) & NamedPipesManager.IsConnected(HubOutPipe))
{
NamedPipesManager.ClosePipe(HubOutPipe);
}
//SendMessage method of NamedPipesManager class.
if (Message != null)
{
byte Buffer = Encoding.Default.GetBytes(MessageType.ToString("D") + " " + Message);
Pipe.Write(Buffer, 0, Buffer.Length); //L'esecuzione si blocca qui.
}
else
{
byte Buffer = Encoding.Default.GetBytes(MessageType.ToString("D"));
Pipe.Write(Buffer, 0, Buffer.Length); //L'esecuzione si blocca qui.
}
Semaphore.Release();
//ReceiveMessage method of NamedPipesManager class
MessageType = MESSAGES.NONE;
Message = null;
System.Diagnostics.Debugger.Break();
StringBuilder sb = new StringBuilder();
byte Buffer = new byte[10];
string Chunk = string.Empty;
while (Pipe.IsConnected)
{
int BytesRead = Pipe.Read(Buffer, 0, Buffer.Length);
do
{
Chunk = Encoding.Default.GetString(Buffer);
sb.Append(Chunk);
Buffer = new byte[10];
}
while (!Pipe.IsMessageComplete);
string MessageReceived = sb.ToString();
MessageType = (MESSAGES)Convert.ToInt32(MessageReceived[0].ToString());
if (MessageReceived.Length > 1)
{
Message = MessageReceived.Substring(3);
}
}
Semaphore.Release();
c# .net winforms named-pipes
I'm trying to develop two applications which, while running, communicate to each other through named pipes, the server application create two pipes, one to send data to clients, the other to receive data from it.
Writing and reading operations are handled in another thread by using a Task, there are no problems while creating the pipes or connecting to them.
There is a problem when the client attempts to write data in the pipe, once the Write method is called, the execution just stops.
//Server code
//NamedPipesManager is a class created by me.
while (!TasksStopper.IsCancellationRequested)
{
if (!NamedPipesManager.IsConnected(OutPipe) & !NamedPipesManager.IsConnected(InPipe))
{
OutPipe.WaitForConnection();
InPipe.WaitForConnection();
}
CanReceiveMessages.WaitOne(); //The server start reading data only when signaled by the client, so that there is always data to read.
MessagesSemaphore.WaitOne(); //The methods of the class can be run only by one thread at a time, a Semaphore is used to regulate access.
NamedPipesManager.ReceiveMessage(InPipe, out MessageReceived.MessageType, out MessageReceived.Response);
if (MessageReceived.MessageType == NamedPipesManager.MESSAGES.CUSTOM_PROJECT_PATH_REQUEST)
{
MessagesSemaphore.WaitOne();
NamedPipesManager.SendMessage(OutPipe, NamedPipesManager.MESSAGES.CUSTOM_PROJECT_PATH_REQUEST, Convert.ToString(CustomProjectsPath));
}
else if (MessageReceived.MessageType == NamedPipesManager.MESSAGES.DEFAULT_PROJECTS_PATH_REQUEST)
{
MessagesSemaphore.WaitOne();
NamedPipesManager.SendMessage(OutPipe, NamedPipesManager.MESSAGES.DEFAULT_PROJECTS_PATH_REQUEST, DefaultProjectsPath);
}
}
if (NamedPipesManager.IsConnected(OutPipe))
{
MessagesSemaphore.WaitOne();
NamedPipesManager.SendMessage(OutPipe, NamedPipesManager.MESSAGES.DISCONNECT, null);
OutPipe.WaitForPipeDrain();
}
//Client code
NamedPipeClientStream HubInPipe = null;
NamedPipeClientStream HubOutPipe = null;
while (!TasksStopper.IsCancellationRequested)
{
HubInPipe = NamedPipesManager.ConnectToNamedPipe(null, "ProjectExchangeAppOutPipe", NamedPipesManager.PIPE_DIRECTION.IN);
HubInPipe.ReadMode = PipeTransmissionMode.Message;
HubOutPipe = NamedPipesManager.ConnectToNamedPipe(null, "ProjectExchangeAppInPipe", NamedPipesManager.PIPE_DIRECTION.OUT);
HubOutPipe.ReadMode = PipeTransmissionMode.Message;
PipesConnectedEvent.Set();
SendMessageEvent.WaitOne();
MessagesSemaphore.WaitOne();
NamedPipesManager.SendMessage(HubOutPipe, MessageType, MessageToSend);
HubWaitHandle.Set();
MessagesSemaphore.WaitOne();
NamedPipesManager.ReceiveMessage(HubInPipe, out ReceivedMessage.MessageType, out ReceivedMessage.Response);
if (ReceivedMessage.MessageType == NamedPipesManager.MESSAGES.CUSTOM_PROJECT_PATH_REQUEST || ReceivedMessage.MessageType == NamedPipesManager.MESSAGES.DEFAULT_PROJECTS_PATH_REQUEST)
{
ReceivedMessages.Add(ReceivedMessage);
MessageReceivedEvent.Set();
}
else if (ReceivedMessage.MessageType == NamedPipesManager.MESSAGES.SETTINGS_PROFILE_CHANGED)
{
DialogResult result = MessageBox.Show("...", "Avviso", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
if (result == DialogResult.Yes)
{
ProfileName = ReceivedMessage.Response;
}
}
else if (ReceivedMessage.MessageType == NamedPipesManager.MESSAGES.DISCONNECT)
{
NamedPipesManager.ClosePipe(HubInPipe);
NamedPipesManager.ClosePipe(HubOutPipe);
}
}
if (NamedPipesManager.IsConnected(HubInPipe) & NamedPipesManager.IsConnected(HubOutPipe))
{
NamedPipesManager.ClosePipe(HubInPipe);
NamedPipesManager.ClosePipe(HubOutPipe);
}
else if (NamedPipesManager.IsConnected(HubInPipe) & !NamedPipesManager.IsConnected(HubOutPipe))
{
NamedPipesManager.ClosePipe(HubInPipe);
}
else if (!NamedPipesManager.IsConnected(HubInPipe) & NamedPipesManager.IsConnected(HubOutPipe))
{
NamedPipesManager.ClosePipe(HubOutPipe);
}
//SendMessage method of NamedPipesManager class.
if (Message != null)
{
byte Buffer = Encoding.Default.GetBytes(MessageType.ToString("D") + " " + Message);
Pipe.Write(Buffer, 0, Buffer.Length); //L'esecuzione si blocca qui.
}
else
{
byte Buffer = Encoding.Default.GetBytes(MessageType.ToString("D"));
Pipe.Write(Buffer, 0, Buffer.Length); //L'esecuzione si blocca qui.
}
Semaphore.Release();
//ReceiveMessage method of NamedPipesManager class
MessageType = MESSAGES.NONE;
Message = null;
System.Diagnostics.Debugger.Break();
StringBuilder sb = new StringBuilder();
byte Buffer = new byte[10];
string Chunk = string.Empty;
while (Pipe.IsConnected)
{
int BytesRead = Pipe.Read(Buffer, 0, Buffer.Length);
do
{
Chunk = Encoding.Default.GetString(Buffer);
sb.Append(Chunk);
Buffer = new byte[10];
}
while (!Pipe.IsMessageComplete);
string MessageReceived = sb.ToString();
MessageType = (MESSAGES)Convert.ToInt32(MessageReceived[0].ToString());
if (MessageReceived.Length > 1)
{
Message = MessageReceived.Substring(3);
}
}
Semaphore.Release();
c# .net winforms named-pipes
c# .net winforms named-pipes
asked Nov 14 '18 at 18:53
dt_overflowdt_overflow
162
162
1
Could it be the case that the reading side is not reading? The pipe buffers might be full.
– usr
Nov 14 '18 at 19:05
The server starts to read data only when signaled by the client through a global EventWaitHandle, the client notifies the server only after writing to the pipe but, since the write operation never completes, the notification isn't sent.
– dt_overflow
Nov 14 '18 at 19:41
It seems better to not use an event at all but to make the server continuously read from the pipe. What do you need to event for?
– usr
Nov 14 '18 at 20:09
Without the event the server becomes unresponsive and the call of the client to the Write method still doesn't return.
– dt_overflow
Nov 14 '18 at 23:52
Understand why that happens and fix the bug. The event complicates the solution and makes it not work. Pipe buffers are limited. Both sender and receiver need to take that into account. The receiver must be able to receive partial messages and piece them together. Often, this is done by sending a length prefix.
– usr
Nov 15 '18 at 8:41
add a comment |
1
Could it be the case that the reading side is not reading? The pipe buffers might be full.
– usr
Nov 14 '18 at 19:05
The server starts to read data only when signaled by the client through a global EventWaitHandle, the client notifies the server only after writing to the pipe but, since the write operation never completes, the notification isn't sent.
– dt_overflow
Nov 14 '18 at 19:41
It seems better to not use an event at all but to make the server continuously read from the pipe. What do you need to event for?
– usr
Nov 14 '18 at 20:09
Without the event the server becomes unresponsive and the call of the client to the Write method still doesn't return.
– dt_overflow
Nov 14 '18 at 23:52
Understand why that happens and fix the bug. The event complicates the solution and makes it not work. Pipe buffers are limited. Both sender and receiver need to take that into account. The receiver must be able to receive partial messages and piece them together. Often, this is done by sending a length prefix.
– usr
Nov 15 '18 at 8:41
1
1
Could it be the case that the reading side is not reading? The pipe buffers might be full.
– usr
Nov 14 '18 at 19:05
Could it be the case that the reading side is not reading? The pipe buffers might be full.
– usr
Nov 14 '18 at 19:05
The server starts to read data only when signaled by the client through a global EventWaitHandle, the client notifies the server only after writing to the pipe but, since the write operation never completes, the notification isn't sent.
– dt_overflow
Nov 14 '18 at 19:41
The server starts to read data only when signaled by the client through a global EventWaitHandle, the client notifies the server only after writing to the pipe but, since the write operation never completes, the notification isn't sent.
– dt_overflow
Nov 14 '18 at 19:41
It seems better to not use an event at all but to make the server continuously read from the pipe. What do you need to event for?
– usr
Nov 14 '18 at 20:09
It seems better to not use an event at all but to make the server continuously read from the pipe. What do you need to event for?
– usr
Nov 14 '18 at 20:09
Without the event the server becomes unresponsive and the call of the client to the Write method still doesn't return.
– dt_overflow
Nov 14 '18 at 23:52
Without the event the server becomes unresponsive and the call of the client to the Write method still doesn't return.
– dt_overflow
Nov 14 '18 at 23:52
Understand why that happens and fix the bug. The event complicates the solution and makes it not work. Pipe buffers are limited. Both sender and receiver need to take that into account. The receiver must be able to receive partial messages and piece them together. Often, this is done by sending a length prefix.
– usr
Nov 15 '18 at 8:41
Understand why that happens and fix the bug. The event complicates the solution and makes it not work. Pipe buffers are limited. Both sender and receiver need to take that into account. The receiver must be able to receive partial messages and piece them together. Often, this is done by sending a length prefix.
– usr
Nov 15 '18 at 8:41
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53306971%2fnamedpipeclientstream-write-not-returning%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53306971%2fnamedpipeclientstream-write-not-returning%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
Could it be the case that the reading side is not reading? The pipe buffers might be full.
– usr
Nov 14 '18 at 19:05
The server starts to read data only when signaled by the client through a global EventWaitHandle, the client notifies the server only after writing to the pipe but, since the write operation never completes, the notification isn't sent.
– dt_overflow
Nov 14 '18 at 19:41
It seems better to not use an event at all but to make the server continuously read from the pipe. What do you need to event for?
– usr
Nov 14 '18 at 20:09
Without the event the server becomes unresponsive and the call of the client to the Write method still doesn't return.
– dt_overflow
Nov 14 '18 at 23:52
Understand why that happens and fix the bug. The event complicates the solution and makes it not work. Pipe buffers are limited. Both sender and receiver need to take that into account. The receiver must be able to receive partial messages and piece them together. Often, this is done by sending a length prefix.
– usr
Nov 15 '18 at 8:41