问题描述
我想在树莓派设备上的两个进程之间建立通信。一种过程用C
语言编写,另一种过程用dot net core
借助以下示例,我能够创建一个命名管道并从该管道读取
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <string.h>
/*https://raspBerry-projects.com/pi/programming-in-c/pipes/named-pipes-fifos*/
#define OUR_INPUT_FIFO_NAME "/tmp/my_fifo"
int main()
{
printf("Hello World!");
int result;
int fs = -1;
result = mkfifo(OUR_INPUT_FIFO_NAME,0777);
if ( result == 0 )
{
printf("New FIFO,%s created successfully",OUR_INPUT_FIFO_NAME);
}
fs = open(OUR_INPUT_FIFO_NAME,(O_RDONLY | O_NONBLOCK));
if ( fs != -1 )
{
printf("Successfully opend %s",OUR_INPUT_FIFO_NAME);
}
while(1)
{
unsigned char buffer[256];
memset(buffer,sizeof(buffer));
int len = read(fs,(void *)buffer,sizeof(buffer));
if ( len == 0 )
{
printf("Sleeping \r\n");
sleep(1);
}
else
{
printf("Data received : %s \r\n",buffer);
}
}
return 0;
}
现在,我正试图为.net core application
进程通过/tmp/my_fifo
进程通过命名管道(C
)接收消息的方法。
我在.net核心中的NamedPipeServerStreame
上找到了一些文档,但是我想我们必须在.net核心中同时拥有客户端和服务器。
有指针吗?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)