neha16 has asked for the wisdom of the Perl Monks concerning the following question:

I have least knowledge on network domain.Please bare with my question if it is basic

I would like to know how to communicate between two applications using "TCP/ip protocol" in "windows XP" say for example

Using Perl and TK I am building a GUI with entry widget and i have an other external application which is installed in the system say "APPLICATION.exe" and also

how to create and set the 1."socket handle", 2."The address of the destination in network-byte order", 3."The port of the destination in host-byte order" for my perl program in APPLICATION.exe and vice versa.

I need to establish the connection using "TCP" between my perl program and external application APPLICATION.exe

for testing purpose what ever I type in the GUI Entry this external application has to receive (hope it receives as bytes)and external application will send some data and i need to process that data in my perl program..

I am totally unaware whether this is simple task or complicated. If there are any modules existing in perl for similar programming please suggest me. I highly appreciate if anyone can provide me the answer with an example.

Thanks to all

Replies are listed 'Best First'.
Re: Interprocess communication in windows xp
by eyepopslikeamosquito (Archbishop) on Apr 13, 2012 at 10:41 UTC

    Excellent support for TCP sockets is built into the Perl core. It is straightforward to write both servers and clients using sockets in Perl. These sort of programs tend to be very portable; that is, most Perl TCP socket programs will "just work" on both Windows and Unix without requiring any special care on the part of the programmer. As for getting started, see, for example: perlipc, IO::Socket and Socket programming in Perl.

Re: Interprocess communication in windows xp
by halfcountplus (Hermit) on Apr 13, 2012 at 11:14 UTC

    For tcp/ip sockets, use: IO::Socket::INET

    2."The address of the destination in network-byte order", 3."The port of the destination in host-byte order"

    You won't need to worry about byte order in perl. In fact, you don't even need to use a numerical address; if it is all on one machine, just use 'localhost'.

    One of the programs will act as a server, the other will act as a client. If you say a little more about the nature and purpose of the communication, someone can give you an opinion about which should be which. You may also want to consider UDP sockets instead of TCP (in which case there is no client server relationship); I have not done this specifically in perl but it works very well for localhost applications, and there is Net::UDP.

    One probably issue will be the need to thread the socket with the GUI, or use some kind of event driven model, since (generally) the socket and the interface need to make themselves available simultaneously. I don't think the Tk module alone has facilities for this.

    I am totally unaware whether this is simple task or complicated.

    If you haven't done it before and you have to deal with the concurrency issue, don't expect to get it done today. ;) You might want to tackle this by first coming up with a model for the socket communication outside the context of your GUI app, then thinking about how to incorporate it.

      Hi thanks..

      Actually Application.exe uses TCP\IP APIs to interact with the other application as example say MSWORD...

      now i need my perl program to communicate with this Application.exe.. Application.exe have configured socket,address,port of MSWORD ..

      now my real thought is how to configure this application.exe ie socket,address,port to communicate with my perl program.. and What i should program in my perl program to establish the connection and communicate

        socket,address,port of MSWORD

        Sorry, to say this, but I think you may be a little confused about those things. AFAIK, MSWORD doesn't use sockets for anything.


        With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.

        The start of some sanity?

        In other words, you didn't write Application.exe and cannot modify it.

        That may present some challenges depending on if and how well the socket interface is documented. Presumably, it is running as a server. You need to determine how the protocol it uses works; if there is no documentation for this you must do it by observing it interact with whatever client it was intended to work with. That means eavesdropping on the connection with something like wireshark.

        now my real thought is how to configure this application.exe ie socket,address,port to communicate with my perl program
        What is this mysterious Application.exe? Is it a commercial product? An open source tool? Or was it written in-house by someone else in your company? I'm assuming you didn't write it since you don't know how to configure it.

Re: Interprocess communication in windows xp
by Corion (Patriarch) on Apr 13, 2012 at 16:50 UTC
Re: Interprocess communication in windows xp
by BrowserUk (Patriarch) on Apr 13, 2012 at 10:12 UTC

    Does "application.exe" already expect to receive input from a socket and send its output to a socket?


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

    The start of some sanity?

Re: Interprocess communication in windows xp
by MidLifeXis (Monsignor) on Apr 13, 2012 at 12:07 UTC

    If you are not familiar with the TCP/IP stack model and network programming and want to read some of the classics, Rick Stevens is an author you may want to get familiar with.

    --MidLifeXis

Re: Interprocess communication in windows xp
by Anonymous Monk on Apr 13, 2012 at 12:51 UTC