Hello,
For an IPC I used sockets for a long time. That's convenient and relatively fast.
Then I thought, at least when the 2 processes are on the same machine, that I could gain speed by using pipes instead. My idea of pipes was that they were using shared memory. But it turns out that my pipe communication is as slow as my socket communication. How can that be? Am I doing something wrong?
Currently, I have implemented the pipes on Windows, but if I can obtain a speed increase, I also want to do this on Linux.
Here my pipe implementation, client side:
// connect to an existing pipe:
HANDLE pipe=CreateFile("\\\\.\\Pipe\\myPipe",GENERIC_READ|GENERIC_WRITE,0,0,OPEN_EXISTING,0,0);
// Write something:
DWORD bytesWritten;
WriteFile(pipe,buffer,bufferSize,&bytesWritten,0)
// Read something:
DWORD bytesRead;
ReadFile(pipe,buffer,bufferSize,&bytesRead,0)
And here my pipe implementation, server side:
// Create the pipe:
HANDLE pipe=CreateNamedPipe("\\\\.\\Pipe\\myPipe",PIPE_ACCESS_DUPLEX,PIPE_TYPE_BYTE|PIPE_READMODE_BYTE|PIPE_WAIT,PIPE_UNLIMITED_INSTANCES,3000000,3000000,NMPWAIT_USE_DEFAULT_WAIT,NULL);
// Connect to client:
if (_pipe!=INVALID_HANDLE_VALUE)
ConnectNamedPipe(_pipe,NULL);
// Read and write from client is implemented in the same was as for the client read/write routines
Anything I am doing wrong?