...

View Full Version : Background UDP message Transmission



myspiel
07-22-2009, 08:17 PM
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.

RabidMango
07-22-2009, 09:24 PM
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

Shannon Blonk
07-23-2009, 12:15 AM
print "status: 204 No Response\n";
print "content-type: text/html;\n\n";
exit;

myspiel
07-23-2009, 02:09 PM
Thank you,

Worked like a charm.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum