Jump to content

  • Log In with Google      Sign In   
  • Create Account


codingJoe

Member Since 22 Oct 2012
Offline Last Active Apr 14 2014 06:04 PM

#5147017 My sockets are as fast as pipes..

Posted by codingJoe on 14 April 2014 - 05:23 PM

Thanks for the insightful comments!

So if I understood correctly, using shared memory is the solution. But still no guarantee for a speed increase.

I'll try my hands on this, thanks again




#5146956 My sockets are as fast as pipes..

Posted by codingJoe on 14 April 2014 - 12:47 PM

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?
 




PARTNERS