Network Pipes

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Lou

    #1

    Network Pipes

    How do i connect to a named pipe as a client?
    -Lou


  • Nicholas Paldino [.NET/C# MVP]

    #2
    Re: Network Pipes

    Lou,

    You can call the CreateFile API through the P/Invoke layer. Once you
    have the handle to the pipe, you can pass it to the constructor of the
    FileStream class to read from/write to it.

    Hope this helps.


    --
    - Nicholas Paldino [.NET/C# MVP]
    - mvp@spam.guard. caspershouse.co m

    "Lou" <lou.garvin@com cast.net> wrote in message
    news:OWnP9HOuDH A.2224@TK2MSFTN GP09.phx.gbl...[color=blue]
    > How do i connect to a named pipe as a client?
    > -Lou
    >
    >[/color]


    Comment

    • Lou

      #3
      Re: Network Pipes

      What is the P/Invoke layer?
      using ?????



      "Nicholas Paldino [.NET/C# MVP]" <mvp@spam.guard .caspershouse.c om> wrote in
      message news:%23Lid6OOu DHA.540@tk2msft ngp13.phx.gbl.. .[color=blue]
      > Lou,
      >
      > You can call the CreateFile API through the P/Invoke layer. Once you
      > have the handle to the pipe, you can pass it to the constructor of the
      > FileStream class to read from/write to it.
      >
      > Hope this helps.
      >
      >
      > --
      > - Nicholas Paldino [.NET/C# MVP]
      > - mvp@spam.guard. caspershouse.co m
      >
      > "Lou" <lou.garvin@com cast.net> wrote in message
      > news:OWnP9HOuDH A.2224@TK2MSFTN GP09.phx.gbl...[color=green]
      > > How do i connect to a named pipe as a client?
      > > -Lou
      > >
      > >[/color]
      >
      >[/color]


      Comment

      • Lou

        #4
        Re: Network Pipes

        Here is my code snippet

        using System;

        using System.Runtime. InteropServices ;

        using System.IO;

        using Microsoft.Win32 ;


        public int ConnectToPipe(s tring machineName,str ing pipeName)

        {

        string connectionStrin g;

        int res;

        connectionStrin g="\\\\" + machineName +"\\" + pipeName;


        res = WaitNamedPipe(c onnectionString , 5000);


        }'



        "Lou" <lou.garvin@com cast.net> wrote in message
        news:uVAUUGPuDH A.2360@TK2MSFTN GP10.phx.gbl...[color=blue]
        > What is the P/Invoke layer?
        > using ?????
        >
        >
        >
        > "Nicholas Paldino [.NET/C# MVP]" <mvp@spam.guard .caspershouse.c om> wrote[/color]
        in[color=blue]
        > message news:%23Lid6OOu DHA.540@tk2msft ngp13.phx.gbl.. .[color=green]
        > > Lou,
        > >
        > > You can call the CreateFile API through the P/Invoke layer. Once[/color][/color]
        you[color=blue][color=green]
        > > have the handle to the pipe, you can pass it to the constructor of the
        > > FileStream class to read from/write to it.
        > >
        > > Hope this helps.
        > >
        > >
        > > --
        > > - Nicholas Paldino [.NET/C# MVP]
        > > - mvp@spam.guard. caspershouse.co m
        > >
        > > "Lou" <lou.garvin@com cast.net> wrote in message
        > > news:OWnP9HOuDH A.2224@TK2MSFTN GP09.phx.gbl...[color=darkred]
        > > > How do i connect to a named pipe as a client?
        > > > -Lou
        > > >
        > > >[/color]
        > >
        > >[/color]
        >
        >[/color]


        Comment

        • Lou

          #5
          Re: Network Pipes

          CreateFile returns a int
          The FileSystemObjec tcs contructor won't take an int???

          I can get a handle using CreateFile but the fileSystemObjec t chokes on it???


          "Nicholas Paldino [.NET/C# MVP]" <mvp@spam.guard .caspershouse.c om> wrote in
          message news:%23Lid6OOu DHA.540@tk2msft ngp13.phx.gbl.. .[color=blue]
          > Lou,
          >
          > You can call the CreateFile API through the P/Invoke layer. Once you
          > have the handle to the pipe, you can pass it to the constructor of the
          > FileStream class to read from/write to it.
          >
          > Hope this helps.
          >
          >
          > --
          > - Nicholas Paldino [.NET/C# MVP]
          > - mvp@spam.guard. caspershouse.co m
          >
          > "Lou" <lou.garvin@com cast.net> wrote in message
          > news:OWnP9HOuDH A.2224@TK2MSFTN GP09.phx.gbl...[color=green]
          > > How do i connect to a named pipe as a client?
          > > -Lou
          > >
          > >[/color]
          >
          >[/color]


          Comment

          • Nicholas Paldino [.NET/C# MVP]

            #6
            Re: Network Pipes

            Lou,

            Your definition of CreateFile should return an IntPtr, not an int. You
            use IntPtr for things such as pointers, handles, etc, etc, where the size of
            the integer is dependent on the platform.

            --
            - Nicholas Paldino [.NET/C# MVP]
            - mvp@spam.guard. caspershouse.co m

            "Lou" <lou.garvin@com cast.net> wrote in message
            news:eIlHgpQuDH A.2368@TK2MSFTN GP09.phx.gbl...[color=blue]
            > CreateFile returns a int
            > The FileSystemObjec tcs contructor won't take an int???
            >
            > I can get a handle using CreateFile but the fileSystemObjec t chokes on[/color]
            it???[color=blue]
            >
            >
            > "Nicholas Paldino [.NET/C# MVP]" <mvp@spam.guard .caspershouse.c om> wrote[/color]
            in[color=blue]
            > message news:%23Lid6OOu DHA.540@tk2msft ngp13.phx.gbl.. .[color=green]
            > > Lou,
            > >
            > > You can call the CreateFile API through the P/Invoke layer. Once[/color][/color]
            you[color=blue][color=green]
            > > have the handle to the pipe, you can pass it to the constructor of the
            > > FileStream class to read from/write to it.
            > >
            > > Hope this helps.
            > >
            > >
            > > --
            > > - Nicholas Paldino [.NET/C# MVP]
            > > - mvp@spam.guard. caspershouse.co m
            > >
            > > "Lou" <lou.garvin@com cast.net> wrote in message
            > > news:OWnP9HOuDH A.2224@TK2MSFTN GP09.phx.gbl...[color=darkred]
            > > > How do i connect to a named pipe as a client?
            > > > -Lou
            > > >
            > > >[/color]
            > >
            > >[/color]
            >
            >[/color]


            Comment

            Working...