This library is a simple support for using bidirectional namedpipes with python.
This library works on windows only.
Install on Windows see Download section, just launch the executable file.
setup.py install
setup.py install -cmingw32
Here is an exemple of python interracting with CPP. Launch the python script first, then compile and launch the test program.
python code
import pipe
pipe.create('\\.\PIPE\mypipe')
print pipe.read()
pipe.write('hello from python')
pipe.close()
cpp code
#include <iostream>
#include <fstream>
#include <windows.h>
#define pipename "\\.\PIPE\mypipe"
using namespace::std;
int main(void){
char buffer[512];
DWORD read_ret;
HANDLE hPipe=CreateFile(pipename, GENERIC_READ|GENERIC_WRITE,
FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
strcpy(buffer, "hello from cpp");
WriteFile(hPipe,buffer, sizeof(buffer), &read_ret, NULL);
ReadFile(hPipe, buffer, sizeof(buffer), &read_ret, NULL);
buffer[read_ret]='\0';
cout << buffer << endl;
CloseHandle(hPipe);
}