This page was last modified 21:11, 26 October 2007.
Exemplos de pipes rotulados
From Forum Nokia Wiki
Original: Named Pipes Example
O código a seguir mostra como usar pipes rotulados.
#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; // Início da thread 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) { // possivelmente o arquivo já existe, apague-o unlink(fifopath); // tente outra vez... 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 |
| Handling Message Threads and Failovers | nights_out | General Messaging | 0 | 2003-05-15 11:09 |
| Problems with threads | tsharju | Python | 12 | 2007-03-02 09:34 |
| Connection not working on phone, does on emulator | mattmatt | Symbian Networking & Messaging | 1 | 2007-03-15 15:41 |
| Cannot remove Widsets from Nokia N81 | alegrange | General WidSets and Widget Discussion | 6 | 2008-07-01 18:55 |
| j2me inlining/optimisation | Sillytuna | Mobile Java General | 13 | 2004-06-29 17:51 |
