Results 1 to 15 of 15

Thread: [VB6] PipeRPC - RPC Over Named Pipes

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Lightbulb [VB6] PipeRPC - RPC Over Named Pipes

    Title

    PipeRPC, a UserControl providing remote procedure calls over Named Pipes written in VB6.

    Description

    PipeRPC is a VB6 UserControl that uses Named Pipes to provide a very easy to use mechanism to make calls between clients and servers running (a.) in the same machine or (b.) across a Local Area Network.

    No more fighting with the Winsock control.

    No more struggling with DCOM (PipeRPC is great for portable applications that use reg-free COM).

    None of the ugliness of Web Services.

    Feature list
    • Client and server functionality in one control.
    • Clients can make connected or disconnected (one time) calls.
    • Uses Named Pipes, so no firewall rules are required.
    • Works whether your LAN is based on TCP/IP, NetBEUI, or IPX/SPX network protocols. No TCP/IP required!
    • So easy.... well anyone can do it.

    Screenshot

    N/A since this is not a visible control at runtime.

    Author name

    Bob Riemersma

    System requirements

    Requires Windows 2000 or later.

    For machine-to-machine operation:
    Windows Networking enabled, firewalls must permit Windows Networking traffic ("File and Print Sharing").

    A common Workgroup or Domain and common Users. The Windows Client and Server services must be running.
    No special processor, disk, or memory requirements. Requires Visual Basic 6.0 development system, preferably Service Pack 6b or later, Standard Edition or better.

    License info

    Copyright © 2011 Robert D. Riemersma, Jr.
    All Rights Reserved

    PipeRPC is free for general use for any legal purpose, and derivative works are encouraged. Users are responsible for determining fitness and proper use. No liability is accepted and no warranty or guarantee of support is offered. This is “as is” software and related documentation and examples.

    PipeRPC and related materials may be freely distributed in source or binary form as long as the notices are kept intact. Programs using PipeRPC do not require attribution in documentation or at runtime, however there is a Copyright property programs could use to display such information in About dialogs, etc. if desired.

    Usage

    Add the UserControl to your VB6 project. PipeRPC.rtf contains developer documentation, sample projects are also included in the package.

    A Minimal Client and Server

    Here is a "calculation client" that passes two operands and an operator to the server and displays the returned result:
    Code:
    Option Explicit
    
    Private Request() As Byte
    Private Response() As Byte
    Private Operation As String
    
    Private Sub cmdCalculate_Click()
        Request = txtA.Text & "|" _
                & Operation & "|" _
                & txtB.Text
        ReDim Response(199)
        pipeCalculate.PipeCall Request, Response
        txtResults.Text = Response
        txtA.SetFocus
    End Sub
    
    Private Sub Form_Load()
        Operation = "+"
    End Sub
    
    Private Sub optOperation_Click(Index As Integer)
        Operation = Choose(Index + 1, "+", "-", "*", "÷")
    End Sub
    Here is the calculation server:
    Code:
    Option Explicit
    
    Private Sub Form_Load()
        pipeCalculate.Listen
    End Sub
    
    Private Sub Form_Unload(Cancel As Integer)
        pipeCalculate.ClosePipe
    End Sub
    
    Private Sub pipeCalculate_Called(ByVal Pipe As Long, Request() As Byte, Response() As Byte)
        Dim ReqParts() As String
        
        ReqParts = Split(Request, "|")
        On Error Resume Next
        Select Case ReqParts(1)
            Case "+"
                Response = CStr(CDbl(ReqParts(0)) + CDbl(ReqParts(2)))
            Case "-"
                Response = CStr(CDbl(ReqParts(0)) - CDbl(ReqParts(2)))
            Case "*"
                Response = CStr(CDbl(ReqParts(0)) * CDbl(ReqParts(2)))
            Case "÷"
                Response = CStr(CDbl(ReqParts(0)) / CDbl(ReqParts(2)))
        End Select
        If Err Then Response = Err.Description
    End Sub
    Attached Files Attached Files

  2. #2

    Thread Starter
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: [VB6] PipeRPC - RPC Over Named Pipes

    To clarify the sample code above, several properties such as the PipeName were set via the IDE Properties panel. A working version is included in the attachment above as Demo 2.

  3. #3
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,652

    Re: [VB6] PipeRPC - RPC Over Named Pipes

    Hi dilettante

    Do you have the VB.Net equivalent ?

    I'm in need of implementing a communication channel between applications which are connected in a LAN. What I have in mind is to use TCP class to create the client and listener, and do the communication. But is there a way to use Named Pipes ?

    Thanks

    If my post was helpful to you, then express your gratitude using Rate this Post.
    And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
    My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet

    Social Group: VBForums - Developers from India


    Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...

  4. #4

    Thread Starter
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: [VB6] PipeRPC - RPC Over Named Pipes

    I believe that in .Net they work hard to hide Named Pipes from programmers. While you can use Named Pipes via WCF within a machine I'm pretty sure they don't allow it across a LAN (for "security reasons" they say).

    So you'd have to resort to PInvoke and API calls.

    TCP/IP works fine, it is just slower within a machine and requires firewall rules and stealing/reserving port numbers between and among machines. A lot of people just "Trust The Force" and pick a port number hoping it doesn't collide with another service.

    But you ought to be able to use WCF with TCP between machines, saving you a lot of hand coding working with the Client and Listener.

  5. #5
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,652

    Re: [VB6] PipeRPC - RPC Over Named Pipes

    Thanks for the info

    If my post was helpful to you, then express your gratitude using Rate this Post.
    And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
    My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet

    Social Group: VBForums - Developers from India


    Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...

  6. #6

    Thread Starter
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: [VB6] PipeRPC - RPC Over Named Pipes


  7. #7
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,652

    Re: [VB6] PipeRPC - RPC Over Named Pipes

    Quote Originally Posted by dilettante View Post
    Thanks

    I found a code sample in here. The author had referenced that blog you have posted too.

    If my post was helpful to you, then express your gratitude using Rate this Post.
    And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
    My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet

    Social Group: VBForums - Developers from India


    Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...

  8. #8

    Thread Starter
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: [VB6] PipeRPC - RPC Over Named Pipes

    Small corrections to just the documentation.
    Attached Files Attached Files

  9. #9
    New Member
    Join Date
    Nov 2013
    Posts
    1

    Thumbs up Re: [VB6] PipeRPC - RPC Over Named Pipes

    Hey dilettante!!!
    That's just amazing! Thanks a lot man!!! You helped me a lot!
    Happy codings!

  10. #10
    New Member
    Join Date
    Dec 2013
    Posts
    1

    Re: [VB6] PipeRPC - RPC Over Named Pipes

    hi
    thanks for this article
    when i run this program there is an error: pipe#0 system error 231
    can you help me?i m realy need to it.
    thanks

  11. #11

    Thread Starter
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: [VB6] PipeRPC - RPC Over Named Pipes

    This is:

    ERROR_PIPE_BUSY (231) All pipe instances are busy.
    See System Error Codes.

    Do you have more than 1 client? The PipeRPC control defaults to MaxClients = 1. You can change this a design time or run time before calling the Listen method.

    From the documentation provided:

    MaxClients Property

    This property can only be set while PipeRPC is not listening.

    MaxClients As Integer

    This value can be from 1 to 255 (where 255 means “unlimited”). In many cases you will have just one client, so the default value is 1. PipeRPC makes every attempt to keep unused slots closed to help reduce the memory impact of pipe instances.

  12. #12
    Fanatic Member Black_Storm's Avatar
    Join Date
    Sep 2007
    Location
    any where
    Posts
    575

    Re: [VB6] PipeRPC - RPC Over Named Pipes

    hi i need to get output from ipc pipe.i have a software document with these contents :

    .
    .
    .
    Unfortunately, it's not as easy to test the IPC protocol on Windows, since Windows ports of socat (in
    Cygwin and MSYS2) don't understand named pipes. In the absence of a simple tool to send and receive
    from bidirectional pipes, the echo command can be used to send commands, but not receive replies from
    the command prompt
    .

    You can send commands from a command prompt :
    Code:
    echo commands >\\.\pipe\mypipename
    To be able to simultaneously read and write from the IPC pipe, like on Linux, it's necessary to write an
    external program that uses overlapped file I/O
    (or some wrapper like .NET's NamedPipeClientStream.)

    You can open the pipe in PuTTY as "serial" device. This is not very comfortable, but gives a way to test
    interactively without having to write code
    and NamedPipeClientStream sample is :
    Code:
    using System;
    using System.IO;
    using System.IO.Pipes;
    
    class PipeClient
    {
        static void Main(string[] args)
        {
            using (NamedPipeClientStream pipeClient =
                new NamedPipeClientStream(".", "testpipe", PipeDirection.In))
            {
    
                // Connect to the pipe or wait until the pipe is available.
                Console.Write("Attempting to connect to pipe...");
                pipeClient.Connect();
    
                Console.WriteLine("Connected to pipe.");
                Console.WriteLine("There are currently {0} pipe server instances open.",
                   pipeClient.NumberOfServerInstances);
                using (StreamReader sr = new StreamReader(pipeClient))
                {
                    // Display the read text to the console
                    string temp;
                    while ((temp = sr.ReadLine()) != null)
                    {
                        Console.WriteLine("Received from server: {0}", temp);
                    }
                }
            }
            Console.Write("Press Enter to continue...");
            Console.ReadLine();
        }
    }
    Unfortunately, although I tested many examples in the forum, I still could not get the output from
    Code:
    echo commands >\\.\pipe\mypipename
    for example this command in linux :
    Code:
    echo '{ "command": ["aa", "bb"] }' | socat - /mypipename
    get result :
    Code:
    {"data":xxxxxx,"error":"success"}
    but with convert to pipe in widnows :
    Code:
    echo { "command": ["aa", "bb"] } >\\.\pipe\mypipename
    return hidden data like as empty the only way need connect to that \\.\pipe\mypipename and stream output data

    I also tested your attachment and it did not work, how could I get the output?
    Last edited by Black_Storm; Apr 9th, 2022 at 04:16 PM.

  13. #13
    Hyperactive Member
    Join Date
    Feb 2015
    Location
    Colorado USA
    Posts
    261

    Re: [VB6] PipeRPC - RPC Over Named Pipes

    dilettante,

    I am thinking of converting your control for use in 64-bit VBA. Since it is almost impossible to write a control for 64-bit VBA in VB6/VBA, I thought of converting it to a class module. Before I start, I have 2 questions for you: a) was there a specific reason you wrote this a control instead of a class module (especially since it has no visible component) and b) is there anything you are aware of that would make this conversion impossible? Thanks.

    MountainMan

  14. #14

    Thread Starter
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: [VB6] PipeRPC - RPC Over Named Pipes

    Most likely in order to host a Timer control.

    This was used to poll for new input because we can't just hang on synchronous reads and overlapped I/O is clumsy to accomplish in VB6.

  15. #15

    Thread Starter
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: [VB6] PipeRPC - RPC Over Named Pipes

    Quote Originally Posted by Black_Storm View Post
    I also tested your attachment and it did not work, how could I get the output?
    This is built around CallNamedPipeW. it sounds like you want to do stream I/O instead.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width