Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

what else from port ?

by exilepanda (Monk)
on Jul 17, 2012 at 06:58 UTC ( #982156=perlquestion: print w/ replies, xml ) Need Help??
exilepanda has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks, I am working on XP-pro. I know how to write a little server listening on a port... then I have another scripts can call the server for services. However, the nature of the server is actually listening to localhost only, so why bother to take a TCP trip? Besides I'll need lot of this kind of servers in later development. So I think this is not really effective and necessary. And I don't enjoy to copy and paste the standard declaration for server start up and init those parameters time to time.

But then... I don't know what direction I can expect or investigate to. but if I can make a wish, I hope there can be something can interface like this :

while ( 1 ) { while ( @ARGV ) { # but how to give data to @ARGV when a script is r +unning ? proc_somthing ( shift @ARGV ) ; } sleep 1; }

What else is something like this in the command prompt type file.txt >> PRN1 Of coz I realize printer is kind of device... but if a script can make self like a device could also be an option for me. Any clues for me to start with? Thanks in advance.

Comment on what else from port ?
Select or Download Code
Re: what else from port ?
by Corion (Pope) on Jul 17, 2012 at 07:15 UTC

    If you want to communicate between running processes, perlipc lists about all of the available things. On Windows, you can also look at Win32::Pipe for a mailbox approach, and to Windows Messages if your program has some kind of GUI. But in the end, TCP is one of the well-proven approaches.

      Thanks a lot!! The Pipe thing looks an easy and clean one for me to start with. But do you suggest the TCP approach is better/safer than those pipe stuff ?

        Personally, I try to avoid IPC. If IPC is necessary, I use either files in a directory, a database or TCP, mostly in that order. Files in a directory have the nice advantage that I only need to worry about the server or the client and can manually test things by moving files into the watched directory. A database is good for serializing access if I have more than one watcher for a resource and they all want to grab the same resource/task. I use TCP servers only if I already do some other TCP interaction, like HTTP requests or talking to a mail server etc.. All these approaches are (fairly) network transparent in the sense that as long as the directory is mounted everywhere, the processes can even run on different machines.

        A Win32::Pipe has the advantage of being manually testable because you can copy files to \\.\pipe\yourpipename and your server can easily find out whether it has been started already. It only allows communication in the direction from the client to the server (I think), but you don't have much buffering problems. Using Win32::Pipe isn't that network transparent unless you have administrator privileges and can set up the users so that they are allowed to access \\machine\pipe\yourpipename from other machines.

        I haven't done much with pipes, and I find the file-based approach to be the simplest approach, so I would start that.

Re: what else from port ?
by BrowserUk (Pope) on Jul 17, 2012 at 07:19 UTC
    Any clues for me to start with?

    That would be very hard until you explain much more clearly what you are trying to do. Your description is very confused.

    What kind or services are your trying to provide?

    Can you give one or two concrete examples of what a user would type or click-on to start things off; and what would then happen?


    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?

      The thing I am look for is exactly in server nature. It's just I am trying to get avoid from going through the TCP layer.

      For example, I have a daemon keep monitoring different folders. And while certain condition happen to the files, it raise another perl script to ask for what to do about them. I will input some command via STDIN, and then send back to the daemon server.

      For another example, I have a shortcut on desktop, and I can drop files to it, and it calls a script with a file list as ARGV. the scrip then ask the server if they are identical to some existed files. ( The server has carried all the MD5 code of the monitoring (sub)folders ).

        Windows supports a wealth of IPC mechanisms:

        However, IFAIK, only a few of those are available from Perl. And some of those are via not well tested modules (eg. Win32::Pipe).

        To decide which is appropriate for each particular application, you have to understand the pros & cons of each mechanism. To get advise, you need to supply specific details of each application.

        You can start your investigations here.


        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: what else from port ?
by bulk88 (Priest) on Jul 17, 2012 at 07:54 UTC
      Thanks alot for the module and wiki! The interface looks clean and easy enough for me. I'll take it a try. Thanks!

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://982156]
Approved by marto
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (10)
As of 2014-07-30 02:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (229 votes), past polls