Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Jul 2009
    Thanked 0 Times in 0 Posts

    Background UDP message Transmission

    I am new to webpages and scripting so this might be a simple problem to the more experienced.
    What I am attempting to do is send a UDP message from a webpage to a external server app (outside webserver).

    (Running Web server on linux system.)

    To test this out I created a small webpage (one button) and when the button is clicked it calls a perl script that sends a test message. My problem is that I don't want the perl script to start a new webpage, I just need it to send the message in the background.

    here is the webpage code:
    <head><title>Button Test</title></head>
    <input type="button" name="custom_button_01" value="Rover 1" onclick="document.location.href= 'http://daystar/cgi-bin/second.pl';"/>


    Here is the perl script:
    #!/usr/bin/perl -w
    use IO::Socket;

    my $message = IO::Socket::INET->new(Proto=>"udp",PeerPort=>4000,PeerAddr=>"");

    print "content-type: text/html\n\n";
    print "Hello Perl";

    if I leave out the last two lines so nothing is required to be displayed, I get an Internal Server Error
    Premature end of script headers

    Can anyone point me in the right direction.

  2. #2
    Join Date
    Jul 2009
    Thanked 4 Times in 4 Posts
    Well if you have the gd module or can install it (I'm no good with terminology so I hope I'm saying these things right) then a wild idea you could pursue is instead of printing content-type html, you could print some form of gif, so your onclick would run a script which put a particular image on the page {or more neatly changed a particular image to another} - the image address would just be a perl script but its output an image. (But do remember to give it a random input any time the page is shown to a user, just to ensure that it does always work and doesn't just go to a cache ever)

    OR if your page is 100% static and has nothing on it which can't just be reloaded, print "Location:http://www.blah.blah\n\n"; instead of content-type:text/html\n\n
    Last edited by RabidMango; 07-22-2009 at 10:26 PM. Reason: added the bit in red

  3. #3
    New Coder
    Join Date
    Mar 2009
    Fabric Covered Box
    Thanked 16 Times in 14 Posts
    print "status: 204 No Response\n";
    print "content-type: text/html;\n\n";

  4. #4
    New to the CF scene
    Join Date
    Jul 2009
    Thanked 0 Times in 0 Posts
    Thank you,

    Worked like a charm.


Posting Permissions

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