This page was last modified 05:58, 1 October 2007.
Named Pipes Example
From Forum Nokia Wiki
The following code shows the usage of named pipes(follows the steps given in the above link):
#include <unistd.h> #include <string.h> #include <sys/stat.h> #include <stdio.h> #include <fcntl.h> #include <pthread.h> const char* fifopath = "C:\\mkfifo.file"; unsigned int threadid; // thread entry point void* FifoWriterThread(void* arg) { const char* buf = "somejunk"; TInt fd = open (fifopath, O_WRONLY); if(fd > 0 ) { write(fd, buf, 9); close(fd); } return 0; } void CreateThreadL() { pthread_create(&threadid,(pthread_attr_t *)NULL,FifoWriterThread, NULL); } void OpenForRead() { int err = mkfifo (fifopath, 0666); if(err != 0) { // probably file already exists, delete the file unlink(fifopath); // try once more.. err = mkfifo (fifopath, 0666); if(err != 0) { return; } } CreateThreadL(); char buf[128]; TInt fd = open (fifopath, O_RDONLY); if ( fd ( 0 ) { return ; } err = read (fd, buf, 128); close(fd); unlink(fifopath); } int main() { OpenForRead(); return 0; }
| Related Discussions | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Problems with LogExample | lm.thiago | Symbian Tools & SDKs | 49 | 2007-09-06 01:05 |
| 急!!请问在3rd中如何设置列表的观察器!! | zhx1020 | Symbian | 7 | 2006-05-16 09:57 |
| Start | ashugupta07 | Symbian User Interface | 1 | 2002-09-13 09:41 |
| How to externalize strings ? | bobmorlaix | Mobile Java General | 2 | 2006-04-26 15:58 |
| Player p becomes null after it has started playing audio | sanket2612 | Mobile Java Media (Graphics & Sounds) | 1 | 2008-02-15 19:21 |
