双管道实现进程数据通信
来源:互联网 发布:淘宝改后台是什么意思 编辑:程序博客网 时间:2024/05/01 15:23
我用的服务器端程序如下:
#include "cliser.h"
#include<fcntl.h>
int main(int argc,char *argv[])
{
int res,client_fifo_fd;
char *temp_data_ptr;
int read_res;
mkfifo(SERVER_FIFO_NAME,0777);
res = open(SERVER_FIFO_NAME,O_RDONLY);
if(res == -1)
{
printf("open read server_fifo_name failure/n");
exit(EXIT_FAILURE);
}
printf("res == %d/n",res);
read_res = read(res,temp_data_ptr,256);
printf("read_res = %d/n",read_res);
if(read_res > 0)
{
printf(">>>>>>>>>>>>>>>>>>>>>>>>>>>>server.c/n");
printf("get data from client /n");
printf("data was %s/n",temp_data_ptr);
while(*temp_data_ptr)
{
*temp_data_ptr = toupper(*temp_data_ptr+1);
temp_data_ptr++;
}
client_fifo_fd = open(CLIENT_FIFO_NAME,O_WRONLY);
if(client_fifo_fd == -1)
{
printf("open write client_fifo_name/n");
exit(EXIT_FAILURE);
}
write(client_fifo_fd,temp_data_ptr,BUFFER_SIZE);
}
close(client_fifo_fd);
exit(EXIT_SUCCESS);
}
客户程序如下:#include "cliser.h"
#include<fcntl.h>
int main(int argc,char *argv[])
{
int res;
char buffer[BUFFER_SIZE];
int write_res;
int read_res;
int client_fifo_fd;
memset(buffer,'/0',strlen(buffer));
memcpy(buffer,"Hello world",30);
// unlink(SERVER_FIFO_NAME);
res = open(SERVER_FIFO_NAME,O_WRONLY);
printf("res = %d/n",res);
if(res == -1)
{
printf("open %s write Failure/n",SERVER_FIFO_NAME);
exit(EXIT_FAILURE);
}
write_res = write(res,buffer,strlen(buffer));
if(write_res > 0)
{
printf("*****************************client.c/n");
printf("write some data in fifo/n");
printf("data content was %s/n",buffer);
}
mkfifo(CLIENT_FIFO_NAME,0777);
sleep(5);
client_fifo_fd = open(CLIENT_FIFO_NAME,O_RDONLY);
if(client_fifo_fd == -1)
{
printf("CLinet_fifo_name no write data/n");
exit(EXIT_FAILURE);
}
read_res = read(client_fifo_fd,buffer,strlen(buffer));
if(read_res > 0)
{
printf("from client_fifo fetch data/n");
printf("data content was %s/n",buffer);
}
close(res);
close(client_fifo_fd);
exit(EXIT_SUCCESS);
}
在运行过程中,红色标记的地方通不过,请问可以哪位大哥帮我看下,server从阻塞状态到执行过程中res = 3;但read_res = -1?不知为何解;
- 双管道实现进程数据通信
- 简单双管道后门实现
- 进程间通信之双管道
- 双管道与cmd.exe进程间通信演示
- Visual C++进程间数据通信的实现
- Visual C++进程间数据通信的实现
- Visual C++进程间数据通信的实现
- Visual C++进程间数据通信的实现
- 双管道打开cmdshell
- MFC-双管道
- C语言父子进程shell命令重定向到管道传递(双管道)
- 双管道(CreatePipe)与cmd.exe进程间通信的有关问题 完美解决
- linux 命名管道fifo实现进程间小数据通信
- 双管道cmd反弹程序
- android进程间数据通信
- WinXP远程桌面实现双管理员同时登录
- 软件实现I2S总线数据通信
- IdUDPServer和IdUDPClient 实现数据通信
- 丶杂绪丨
- 广电总局太强了
- .Net的DataSet直接与SQL2005交互
- [Windows编程] 监视DLL装载/卸载
- 浏览器的几个感悟
- 双管道实现进程数据通信
- 什么是泛型编程——Generic Programming
- 微软抠动扳机,对手应声倒下
- ORACLE分页存储过程
- 09年最新的最有才的100句话,不服不行!!
- 理解JavaScript的caller,callee,call,apply
- 学习知识
- 职场新人的入门法则:少想、多做、立即执行!
- 不让用轮子,难道我不会造一个吗?