gheni4
gheni4

Reputation: 303

Is it possible to create and use FIFO file in iOS? (ObjC)

I want to use good old FIFO to pass data to another part of my own iOS application. I looked at dispatch_io_create_with_path but I want the other side to be able to read data with plain read(). Is it possible to use FIFO file? how?

I tried next code in Xcode7 ObjC (path points to Documents dir + filename):

res = mkfifo(path, 0x777);

int fd;
fd = open(path, O_WRONLY);
write(fd, "test", 5);
close(fd);

mkfifo() returns 0 but open() fails with -1. Interestingly if I try open() with 'O_RDONLY' program is waiting so something is happening over there..

Upvotes: 1

Views: 1246

Answers (1)

gheni4
gheni4

Reputation: 303

omg can't believe I wasted hours on that one... well here it is: The error is in the "0x777" part. Should be "0777". After fixing that - FIFO is worked fine for me (iOS 9.2.1).

Upvotes: 2

Related Questions