so i'm trying to send a file (in this case a .jpg image) in binary from a client in python 3 to a C server through pipes and for some reason it displays the error, broken pipe, here is the code: python:
import os,sys,errno,pipes,signal,time
def Tuberia():
fifo = "/tmp/fifoNombre"
print ("conecting to a pipe...",fifo)
file = open("/home/luisro/Pictures/64.jpg","r+b")
f = open(fifo,'wb')
for line in file:
print(line)
f.write(line)
f.close()
file.close()
and the C server:
void reciveFile(){
int fn;
char * fifoNombre = "/tmp/fifoNombre";
// //opens the pipe for reading
mkfifo(fifoNombre, 0666);
unsigned char datos[MAX_BUF];
fn = open(fifoNombre, O_RDONLY);
read(fn, datos, MAX_BUF);
saving(datos,"/home/luisro/Desktop/algo.jpg");
unlink(fifoNombre);
}
void saving(unsigned char *data, char* dirDest){
FILE *flujoArchivo = fopen(dirDest, "wb");
if(flujoArchivo == NULL){
printf("Error saving.\n");
exit(-1);
}
int writed_size = fwrite(data, sizeof(unsigned char), MAX_BUF, flujoArchivo);
fclose(flujoArchivo);
}
so those are the functions i don't know if is the python client or the C server where the problem is, thanks in advance