Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdlib.h>
- #include <stdio.h>
- #include <sys/types.h>
- #include <sys/stat.h>
- #include <fcntl.h>
- #include <unistd.h>
- int main(){
- int fpipe1=0,fpipe2=0,connectMessageSize=7;
- unsigned char sizeFirst=0;
- char *request=NULL;
- mkfifo("RESP_PIPE_11548",0600);
- fpipe1=open("RESP_PIPE_11548",O_RDWR);
- if(fpipe1==-1){
- perror("ERROR OPENING FILE!");
- exit(1);
- }
- fpipe2=open("REQ_PIPE_11548",O_RDWR);
- if(fpipe2==-1){
- perror("ERROR OPENING FILE!");
- exit(1);
- }
- if(write(fpipe1,"CONNECT",connectMessageSize)<0){
- perror("ERROR\ncannot create the response pipe | cannot open the request pipe");
- exit(1);
- }
- printf("SUCCESS\n");
- //AICI PUSCA
- printf("PUSCA\n");
- if(read(fpipe2,&sizeFirst,sizeof(unsigned char))<0){
- perror("ERROR\ncannot read from file");
- exit(1);
- }
- printf("NU A PUSCAT\n");
- request=(char*)malloc(sizeFirst*sizeof(char));
- int readingSize=sizeFirst*sizeof(char);
- if(read(fpipe2,&request,readingSize)<0){
- perror("ERROR\ncannot read request from file!");
- exit(1);
- }
- printf("verif: %s",request);
- free(request);
- close(fpipe1);
- close(fpipe2);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement