Named Pipes using mkfifo and Cocoa

I have a C++ application that uses named pipes by calling mkfifo and I would like to use them to connect to a Cocoa app. I have taken a look at NSPipe but there isn't an option to connect to a named pipe. Does anyone know how to connect NSPipes or something else I can tie into the NSNotificationCenter that can talk to named pipes?
Thank you for your time,
Tom

-(void)SomeFunc
const char * path = "/tmp/tom21";
if(mkfifo(path, 0666) == -1 && errno !=EEXIST){
NSLog(@"Unable to open the named pipe %c", path);
NSFileHandle * filehandleForReading;
int fd = open(path, O_RDWR | O_NDELAY);
filehandleForReading = [[NSFileHandle alloc] initWithFileDescriptor:fd closeOnDealloc: YES];
NSNotificationCenter *nc;
nc = [NSNotificationCenter defaultCenter];
[nc removeObserver:self];
[nc addObserver:self
selector:@selector(dataReady:)
name:NSFileHandleReadCompletionNotification
object:filehandleForReading];
[filehandleForReading readInBackgroundAndNotify];
And then here is the func that gets called by the Notification server
- (void)dataReady:(NSNotification *)n
NSData *d;
d = [[n userInfo] valueForKey:NSFileHandleNotificationDataItem];
NSLog(@"dataReady:%d bytes", [d length]);
if ([d length]) {
[self appendData:d];
//Tell the fileHandler to asychronusly report back
[filehandleForReading readInBackgroundAndNotify];
}

Similar Messages

  • How to read data from Linux named pipes using java?

    In linux box I want to get data from a named pipe(created using "mkfifo <filename>".
    How I can read the incoming data from the named pipe?

    there are some caveats though: if i remember correctly, when you reach the end of data in a fifo it will look like end-of-file and that may confuse some classes. So your mileage may vary

  • Named pipes?

    Hi everyone,
    Anyone knows how to implement a full named pipe using java?
    i am wondering if it is possible to implement a named pipe in windows xp using .net which could "communicate" with a java app.
    Many thanks,

    Hi everyone,
    here is where i am stuck in:
    after reading the article i have a couple of questions:
    how can the command mkfifo in java be implemented?
    Besides, what i have done is as follows:
    i have an app which is using the runtime to create another process in order to receive all the messages from some libraries. For the moment it is receiving all the messages and copying them into a file (this part works perfectly)
    <Master Code>
    FileOutputStream fos = new FileOutputStream("text.txt");//args[0]);
    Runtime rt = Runtime.getRuntime();
    //Process pipe = rt.exec("mkfifo pipe");
    Process proc = rt.exec("java MainInterface");
    StreamGobbler outputGobbler = new
    StreamGobbler(proc.getInputStream(), "OUTPUT", fos);
    // kick them off
    outputGobbler.start();
    <end Master Code>
    <Thread which copyes into a file>
    class StreamGobbler extends Thread
    InputStream is;
    String type;
    OutputStream os;
    StreamGobbler(InputStream is, String type, OutputStream redirect)
    this.is = is;
    this.type = type;
    this.os = redirect;
    public void run()
    try
    PrintWriter pw = null;
    if (os != null)
    pw = new PrintWriter(os);
    InputStreamReader isr = new InputStreamReader(is);
    BufferedReader br = new BufferedReader(isr);
    String line=null;
    while ( (line = br.readLine()) != null)
    if (pw != null)
    pw.println(line);
    System.out.println(type + ">" + line);
    pw.flush();
    if (pw != null)
    pw.flush();
    } catch (IOException ioe)
    ioe.printStackTrace();
    <End Thread which copyes into a file>
    And the app called by this master program, which should show the messages incoming in the pip in a text area:
    <mainInterface>
    public static void main(String[] args) throws IOException{
    javax.swing.SwingUtilities.invokeLater(new Runnable() {
    //Here should be the pipe called
    public void run() {
    createAndShowGUI();
    <End mainInterface>
    Now the point is how can be done to write instead in a file, into a pipe which the mainInterface could access
    Many thanks

  • SetDaemon(true) problem, named pipe communication

    hi all!
    i have a "strange" problem, when running a thread in a daemon mode.
    Thread parsing = new Thread(){
                   public void run(){
                        initParser();
                        String[] __log_data;
                        String line;
                        while(true){
                             _action = 0;
                             try{
                                  line = _comm_in.receive();
                                  __log_data = vpncDataParser(line);
                                  if(_action != 0 )
                                       _comm_out.send(createSOAPQuery(__log_data));
                             }catch(ProbeException pe){
                                  pe.toString();
                             }catch(NullPointerException npe){
                                  npe.toString();
              parsing.setDaemon(false);
              parsing.start();as you see in the code above, i set daemonizing to false...and everything works. but as soon as i set it to true the program exits without exception triggered.
    i use a socket to read data ( _comm_in.receive() ), i used a named pipe before that and hadn't had problems with daemonizing. but there was an another problem - the program exited after a couple of lines read.
    any ideas will be appreciated.
    cheers
    dian

    I wish I did, unfortunately I'm not much of a named pipe guru. I noticed something though, you're calling initParser() in the parsing Thread. I don't see that method in your anonymous inner class so I assume it's in the enclosing class (rather than omitted here for brievity). Similarly commin and commout appear to be from the enclosing class. Since those are in the enclosing class, a number of parsing threads could be messing with them at the same time.
    Is it possible that any of these are getting messed up by another thread while your anonymous inner class is running? For example, if it was doing something like:
    Thread parsing = new Thread(){
                   public void run(){
              parsing.setDaemon(false);
              parsing.start();
              _comm_in = null;    // This would break itI assume it's not that straight-forward, but a more complicated variation of it perhaps? Is it possible for two parsing threads to be running at once? If so, is the second one calling initParser() messing up the first?
    Other than that, if its some weird named-pipe goings on then I'm useless to you :).
    - Jemiah

  • Carbon and Cocoa Integration

    I have read the Cocoa-Carbon Integration Guide several times, but still have one unanswered question. The guide explains how to call Carbon Functions in a Cocoa Objective-C Class File. However, does this also apply to data types? I made the logical connection that it would be hard to call carbon functions without carbon data types, but i don't know if they have to be called in a special way of if a prefix needs to be added to the data types before they can be used. Could someone explain or elaborate on how to use Carbon in Cocoa Classes?
    thx

    Orangekay is right. You can learn it, but don't be in a hurry. If you are familiar with object-oriented Javascript, you should be able to figure it out. Cocoa is a pure object-oriented library where you send messages to receivers.
    [receiver message: argument]
    Carbon is also an object-oriented library, but it is written in C. In Carbon, you would do the above as:
    message(receiver, argument)
    Javascript looks closer to Java or C++ syntax-wise than either Cocoa or Carbon. For an example, compare the interfaces of CFString with NSString. They do the same things and are, in fact, the same objects using Carbon and Cocoa interfaces, respectively.
    There are only a few objects that exist in both Carbon and Cocoa. Most things are either one or the other. Still, all Cocoa objects and methods will look similar. The same is true for Carbon.
    Unfortunately, there are some low level details, like memory management, that you don't have to deal with in Javascript. You may have to step back and work on some simple C or Cocoa projects just to learn before you can apply that to something real.

  • Export and Import using Named Pipes

    Hai,
    I need an clarification in export, import and compress of dumps using named pipes.I am using Oracle 9i RAC 9.2.0.4 in AIX 5.3. Every month i have to move list of tables from one database to another database after taking export dumps. The list of activities done by me at present are given below.
    1. Taking export and gziping the dump file at the same time using named pipes.
    2. Doing uncompress and import in the second database using named pipes.
    We are doing compress for space constraints. Now my doubt is whether using named pipes, we can do both operation of import and compress of dump file at the same time. i.e, at the time of export itself , using named pipes, i need both import in the another database and compress the zip file. Is it possible?

    mknod exp.out p
    exp dbadmin/admindb file=exp.out owner=scott log=export.log statistics=none &
    imp dbadmin/admindb file=exp.out fromuser=scott touser=foobar log=import.log
    rm exp.out
    cat import.log
    Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    Export file created by EXPORT:V10.02.01 via conventional path
    import done in US7ASCII character set and UTF8 NCHAR character set
    import server uses AL32UTF8 character set (possible charset conversion)
    . importing SCOTT's objects into FOOBAR
    . . importing table                        "BONUS"          0 rows imported
    . . importing table                         "DEPT"          4 rows imported
    . . importing table                          "EMP"         14 rows imported
    . . importing table                     "SALGRADE"          5 rows imported
    About to enable constraints...
    Import terminated successfully without warnings.Edited by: sb92075 on Jan 1, 2010 1:42 PM

  • Connecting to sqlserver using named pipe

    I would like to connect to mssql (running on same PC as SQL Developer) using named pipes.
    The host is listed in the Windows Service Manager as \\SX3102971\SIMSLOCAL
    I have gone to the 'Oracle' tab, selected 'Advanced' and in the 'Custom JDBC URL'
    entered
    jdbc:jtds:sqlserver:\\SX3102971\SIMSLOCAL;namedPipe=true;user=<username>;password=<password>
    where <username> and <password> are the true values.
    I receive a message
    Staus : Failure -Invalid connection information specified. Verify the URL format for the specified driver.
    Can anyone advise on what may be wrong?
    Also, can SQLDeveloper handle blank passwords?
    The database is installed as part of a third party application, which sets the default dba logon with no password. SQL Developer states that a password is required. For the example above I have created my own log on.

    Hi,
    I managed to solve the problem. So don't worry about it.
    For others who are looking for the solution...
    - I have referred to the http://www.qint.de/joria/doc/jdbc/jtds.html.
    - I have changed the URL element in IDEConnections.xml file located under where SQLDEVELOPER software is installed.
    - The URL must look like the following ...
    <URL>jdbc:jtds:sqlserver://\\.\;namedPipe=true;instance=<name of the database - without the server name>;</URL>
    Hope this helps.
    Regards
    Raja
    Message was edited by:
    rajaram_r

  • What should be started and enabled in SQL express 2008 R2? Shared memory, TCP/IP , named pipes, VIA

    I copied my Visual Studio 2008 projects to a new computer and am having trouble getting the database to attach to my website to continue with it.
    I uninstalled SQL 2005 express and installed SQL 2008 R2 Express.
    When I looked in the SQL Server configuration manager, I wasn't sure what should be running and what should be stopped and what protocols should be enabled, etc so I started everything and enabled everything.
    However, the SQL Server Agent will not start. Maybe I did something wrong by enabling everything. I have everything to start automatically, and all enabled:
    SQL Native Client: I right clicked and opened and under client protocols, have enabled all: Shared memory, TCP/IP , named pipes, VIA
    and under SQL Server Network Configuration, I opened that and under there is listed protocols for SQLEXPRESS AND I enabled same things: Shared memory, TCP/IP , named pipes, VIA
    When I could not start the SQL Server Agent before from the SQL Server configuration mgr. I went into services and started it that way and it did start. But since I have rebooted, it will not start that way either and I now get this message: Windows could
    not start the SQL Server Agent(SQLEXPRESS) Service on local computer. Error 1067
    I'm just trying to get my visual studio project working again. Would appreciate any help. Maybe I should uninstall SQL and reinstall 2005??

    Windows could not start the SQL Server Agent(SQLEXPRESS) Service on local computer.
    As the others already wrote, with SQL Server Express in Version 2008 the "SQL Server Agent" will be installed, but it's not a Feature of the Express Edition and therefore you can't start & use it.
    In SQL Server 2005 Express the Agent was completly missing (not installed), therefore you haven't this "issue" before.
    Olaf Helper
    [ Blog] [ Xing] [ MVP]

  • Mxi includes on localhost using named pipes

    hello all,
    why does my addt "server side includes" didn't work when using localhost server using named pipes? my port is 8080 and i access the server using http//localhost:8080...
    if i access mysql query browser im using "."(a dot)as my server host.
    there is always a folder permission error but i can use php includes fine.
    can anyone help in making the "server side includes" work?

    There is no use for testing named pipes. As I said - it is an excellent method for IPC. It is slow and unscalable for networking, especially WANs.
    A few minutes of googling this subject and doing some bit of research, would highlight this quite clearly.
    BTW - if you think named pipes are better for tcp, then don't you think Oracle would have recommended its use? Heck, Oracle recommends using the RDS protocol for the RAC Interconnect. A protocol not widely known outside the HPC environment. So surely they would have sung the praises of more commonly known named pipes for tcp if it was any good?
    Which again points to the fact that it ain't good and your wasting your time by trying to be "clever" and barking up the wrong tree.

  • Javascript and Named Pipes

    I am trying to write a script for AE and I want to use named pipes to communicate.  My pipe server is working fine and it's functioning great in .NET when both sides are .NET programs.
    When I connect my AE javascript to the pipe as the client, the server side sees the connection, but the javascript side immediately closes it.  The server reports that the pipe is broken.  For the record, the server is set up for only one client and the .NET client program has been shut down.
    I am just getting started with this, so the code is only a few lines:
    var f = new File("\\\\.\\pipe\\MYPIPE");
    b=f.open ("r");
    $.writeln (b);
    $.writeln (b);
    What's interesting is that the value of "b" is immediately false, and the error is simply "I/O error".
    Anyone have any experience with this?
    Thanks in advance.

    At this point we do not have specific plans for adding shared memory or named pipes support but we appreciate your feedback, and will take it into consideration when planning future release(s). 
    This posting is provided "AS IS" with no warranties, and confers no rights.

  • How can I connect using named pipes ( NMP ) ?

    Hi all,
    I'd like to do compare the availablke protocol (TCP, IPC, BEQ, NMP ) connect to my db, but I'm not able to configure named pipes.
    My *.ora files contain:
    tnsnames.ora:
    ORA10_NMP=
      (DESCRIPTION = 
        (ADDRESS =  
          (PROTOCOL = NMP)   
          (SERVER = 10.10.1.1) 
          (PIPE = ORApipe)
        (CONNECT_DATA = 
          (SID = ORA10)
    listener.ora:
    LISTENER_ORA10 =
      (DESCRIPTION_LIST =
        (DESCRIPTION =
          (ADDRESS_LIST=
            (ADDRESS =
           (PROTOCOL = TCP)
           (HOST = 10.10.1.1)
           (PORT = 1522)
            (ADDRESS =
           (PROTOCOL = IPC)
           (KEY = ORA10)
            (ADDRESS =
           (PROTOCOL = NMP)
           (SERVER = 10.0.0.1)
              (PIPE = ORApipe)
    SID_LIST_LISTENER_ORA10 =
      (SID_LIST=
        (SID_DESC=
          (SID_NAME=ORA10)               
          (ORACLE_HOME=C:\oracle\product\10.2.0\db_1)
      )The network adapter used to connect to 10.10.1.1 is a microsoft loopback adapter , and I installed the "microsoft client ".
    When I try to use the ORA10_NMP alias I always get errors like:
    C:\>c:\oracle\product\10.2.0\db_1\bin\TNSPING.EXE ORA10_NMP
    TNS Ping Utility for 32-bit Windows: Version 10.2.0.5.0 - Production on 24-JUN-2011 14:06:39
    Copyright (c) 1997,  2010, Oracle.  All rights reserved.
    Used parameter files:
    C:\oracle\product\10.2.0\db_1\network\admin\sqlnet.ora
    Used TNSNAMES adapter to resolve the alias
    Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = NMP) (SERVER = 10.10.1.1) (PIPE = ORApipe)) (CONNECT_DATA =
    (SID = ORA10)))
    TNS-12560: TNS:protocol adapter error
    C:\>c:\oracle\product\10.2.0\db_1\bin\sqlplus system/foo@ORA10_NMP
    SQL*Plus: Release 10.2.0.5.0 - Production on Fri Jun 24 14:06:44 2011
    Copyright (c) 1982, 2010, Oracle.  All Rights Reserved.
    ERROR:
    ORA-12560: TNS:protocol adapter error
    Enter user-name:Any suggestion?
    Thanks,
    Andrea

    There is no use for testing named pipes. As I said - it is an excellent method for IPC. It is slow and unscalable for networking, especially WANs.
    A few minutes of googling this subject and doing some bit of research, would highlight this quite clearly.
    BTW - if you think named pipes are better for tcp, then don't you think Oracle would have recommended its use? Heck, Oracle recommends using the RDS protocol for the RAC Interconnect. A protocol not widely known outside the HPC environment. So surely they would have sung the praises of more commonly known named pipes for tcp if it was any good?
    Which again points to the fact that it ain't good and your wasting your time by trying to be "clever" and barking up the wrong tree.

  • Switching from Named Pipes to Tcp/Ip sockets : can I use the same DB or will I loose my data?

    Hi,
    we use MDT 2013 in conjunction with a local SQL Express 2012 database. I configured MDT to use Named Pipes but I want to switch to TCP/IP sockets. Is it possible to change that Network Library for an existing database? Am I going to loose the contents of
    the existing db? Thanks for your insights.
    Paul

    Just did a testrun with a test deployment share. Made a db with Named Pipes, filled in some values. Created a new db and I was able to choose between some existing databases. I chose the test db and yes all the values are in it.
    Next I tried it with my main db and indeed nothing is lost. Pfjew.
    Paul

  • Using utl_file and unix pipes

    Hi,
    I'm trying to use utl_file and unix pipes to communicate with a unix process.
    Basically I want the unix process to read off one pipe and give me back the result on a different pipe.
    In the example below the unix process is a dummy one just copying the input to the output.
    I cant get this to work for a single plsql block writing and reading to/from the pipes - it hangs on the first read of the return pipe.
    Any ideas?
    ======== TEST CASE 1 ===============
    create directory tmp as '/tmp';
    on unix:
    cd /tmp
    mknod outpip p
    mknod inpip p
    cat < inpip > outpip
    drop table res;
    create table res (m varchar2(200));
    declare
    l_filehandle_rec UTL_FILE.file_type;
    l_filehandle_send UTL_FILE.file_type;
    l_char VARCHAR2(200);
    begin
    insert into res values ('starting');commit;
    l_filehandle_send := UTL_FILE.fopen ('TMP', 'inpip', 'A', 32000);
    insert into res values ('opened inpip ');commit;
    l_filehandle_rec := UTL_FILE.fopen ('TMP', 'outpip', 'R', 32000);
    insert into res values ('opened outpip ');commit;
    FOR i in 1..10 LOOP
    utl_file.put_line(l_filehandle_send,'line '||i);
    insert into res values ('written line '||i); commit;
    utl_file.get_line(l_filehandle_rec,l_char);
    insert into res values ('Read '||l_char);commit;
    END LOOP;
    utl_file.fclose(l_filehandle_send);
    utl_file.fclose(l_filehandle_rec);
    END;
    in a different sql session:
    select * from res:
    starting
    opened inpip
    opened outpip
    written line 1
    ============ TEST CASE 2 =================
    However If I use 2 different sql session (not what I want to do...), it works fine:
    1. unix start cat < inpip > outpip
    2. SQL session 1:
    set serveroutput on size 100000
    declare
    l_filehandle UTL_FILE.file_type;
    l_char VARCHAR2(200);
    begin
    l_filehandle := UTL_FILE.fopen ('TMP', 'outpip', 'R', 32000);
    FOR i in 1..10 LOOP
    utl_file.get_line(l_filehandle,l_char);
    dbms_output.put_line('Read '||l_char);
    END LOOP;
    utl_file.fclose(l_filehandle);
    END;
    3. SQL session 2:
    set serveroutput on size 100000
    declare
    l_filehandle UTL_FILE.file_type;
    begin
    l_filehandle := UTL_FILE.fopen ('TMP', 'inpip', 'A', 32000);
    FOR i in 1..10 LOOP
    utl_file.put_line(l_filehandle,'line '||i);
    --utl_lock.sleep(1);
    dbms_output.put_line('written line '||i);
    END LOOP;
    utl_file.fclose(l_filehandle);
    END;
    /

    > it hangs on the first read of the return pipe.
    Correct.
    A pipe is serialised I/O device. One process writes to the pipe. The write is blocked until a read (from another process or thread) is made on that pipe. Only when there is a reader for that data, the writer is unblocked and the actual write I/O occurs.
    The reverse is also true. A read on the pipe is blocked until another process/thread writes data into the pipe.
    Why? A pipe is a memory structure - not a file system file. If the write was not blocked the writer process can writes GBs of data into the pipe before a reader process starts to read that data. This will drastically knock memory consumption and performance.
    Thus the purpose of a pipe is to serve as a serialised blocking mechanism between a reader and a writer - allowing one to write data that is read by the other. With minimal memory overheads as the read must be serviced by a write and a write serviced by a read.
    If you're looking for something different, then you can open a standard file in share mode and write and read from it using two different file handles within the same process. However, the file will obviously have a file system footprint ito space (growing until the writer stops and the reader terminates and trashes the file) .
    OTOH a pipe's footprint is minimal.

  • How to create a Bookmark and set action to a named destination using Acrobat SDK?

    I want to create a bookmark using JSO and set it Bookmark Action to a Named Destination. I am able to select required required paragraph/section using PDTextselect, create a bookmark using JSO but I am not able to set Bookmark Action to a Paragraph/section. Can anyone help me out to set Bookmark Action to a Paragraph/Section. I don't know how to create Named Destination.

    What if we select required text and by ussing App method
    MenuItemExecute call "Highlight Selected Text".
    But what is the Menu Item Name of "Highlight Selected Text" under Tools>Comment & Markup>Text Edit.

  • A process named "update.exe *32" and description is "Firefox" keeps using a lot of memory and cpu; the longer forefox is on, the worse it gets. How to prevent?

    using Windows 7, firefox 15.0.1
    This process uses more and more memory and CPU, sometimes there are several of these processes running. If I kill these processes, it doesn't seem to affect the utilization of Firefox. Then the process slowly starts to use more and more memory and CPU all over again.
    This happens all the time, every time I use Firefox.

    I do not have a ComObjects folder under C:\Program Files (x86)\Common Files. That is not part of Firefox.
    wscript.exe is a utility included with Windows to run scripts at the system level. It generally is not used by major programs. If update.exe is starting up with Windows, you may be able to find the script that wscript.exe is running using [http://technet.microsoft.com/en-us/sysinternals/bb963902.aspx Autoruns].
    It definitely sounds viral. I suggest deleting the update.exe file, although Windows might prevent you from doing that until you kill all related processes. And if you have a persistent infection, the file may be restored or re-downloaded.
    It might be easiest to seek assistance from a forum more dedicated to malware cleanups such as the following:
    * [http://www.bleepingcomputer.com/forums/forum22.html Virus, Trojan, Spyware, and Malware Removal Logs - BleepingComputer.com]
    * [http://forums.majorgeeks.com/forumdisplay.php?f=35 Malware Removal - MajorGeeks Support Forums]
    Hope you get it removed.

Maybe you are looking for

  • Failed engineer appointment and no follow-ups

    Hello, I ordered Infinity 2 on 26th of June and was given an appointment date of 10th July. Hub arrived fine 2 days prior, but on the appointment date no one turned up, nor did I receive any phonecalls or texts from Openreach to explain. Called Order

  • Oddball fix

    hi i tried the bulletsandbones oddball fix for a problem and had no difficulty with repairing permissions, but was unable to locate the garageband preference files to delete them. the FAQ gives directions for S X 5 and older, and i have 10.6.2. is th

  • Open dataset in text mode utf-8 no funciona

    Hola que tal, soy nuevo en el foro tengo un problema espero me puedan ayudar si alguien de casualidad se ha topado con esto, lo que pasa es que necesito descargar un archivo en proceso de fondo que me deje el archivo .txt de tipo UTF-8 no ANSI para l

  • To Send POST Method Value in ProxyServer

    Hello I developed a ProxyServer. Problem is when i send post method value to server...data is not sending correctly. But i can get the value correctly form browser. How can send the post method values. My source code is * ServerThread.java * Created

  • Server Recommendations?

    I have been encountering ongoing problems with a Mac InDesign and PC InCopy workflow on PC Servers. Is there a recommended type of server for optimal performance for InDesign/InCopy workflow? Thanks in advance