.net core 覆盆子皮->;c与dotnet核心进程的通信
我想在我的raspberry pi设备上的两个进程之间建立通信。一个进程用.net core 覆盆子皮->;c与dotnet核心进程的通信,.net-core,cross-platform,ipc,raspbian,named-pipes,.net Core,Cross Platform,Ipc,Raspbian,Named Pipes,我想在我的raspberry pi设备上的两个进程之间建立通信。一个进程用C语言编写,另一个进程用dotnetcore 在下面示例的帮助下,我能够创建一个命名管道并从该管道读取数据 #include <stdio.h> #include <unistd.h> #include <stdlib.h> #include <fcntl.h> #include <sys/types.h> #include <sys/stat.h>
C
语言编写,另一个进程用dotnetcore
在下面示例的帮助下,我能够创建一个命名管道并从该管道读取数据
#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,0,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;
}
#包括
#包括
#包括
#包括
#包括
#包括
#包括
/*https://raspberry-projects.com/pi/programming-in-c/pipes/named-pipes-fifos*/
#定义我们的\u输入\u FIFO\u名称“/tmp/my\u FIFO”
int main()
{
printf(“你好,世界!”);
int结果;
int fs=-1;
结果=mkfifo(我们输入的FIFO名称,0777);
如果(结果==0)
{
printf(“新的FIFO,%s创建成功”,我们的\u输入\u FIFO\u名称);
}
fs=打开(我们的输入FIFO名称,(O_RDONLY | O_NONBLOCK));
如果(fs!=-1)
{
printf(“成功打开%s”,即我们的输入\u FIFO\u名称);
}
而(1)
{
无符号字符缓冲区[256];
memset(buffer,0,sizeof(buffer));
int len=read(fs,(void*)缓冲区,sizeof(buffer));
如果(len==0)
{
printf(“睡眠\r\n”);
睡眠(1);
}
其他的
{
printf(“收到的数据:%s\r\n”,缓冲区);
}
}
返回0;
}
现在,我正试图找到一种方法,使.net核心应用程序
能够通过命名管道(/tmp/my_fifo
)从C
进程接收消息。
我在.NETCore中找到了一些文档,但我想我们必须在.NETCore中同时包含客户端和服务器
有什么建议吗