Hello and welcome to our community! Is this your first visit?
Register
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
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Background UDP message Transmission

    Hello,
    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:
    <html>
    <head><title>Button Test</title></head>
    <body>
    <form>
    <input type="button" name="custom_button_01" value="Rover 1" onclick="document.location.href= 'http://daystar/cgi-bin/second.pl';"/>

    </form>
    </body>
    </html>

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

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

    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
    Banned
    Join Date
    Jul 2009
    Posts
    52
    Thanks
    10
    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 09:26 PM. Reason: added the bit in red

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

  • #4
    New to the CF scene
    Join Date
    Jul 2009
    Posts
    2
    Thanks
    0
    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
    •