Re: Socket/PIPE/Stream to long running process
At 11:04 AM 2/2/01 -0800, Rob Bloodgood wrote: So, in my mod_perl app, I run thru each request, then blast a UDP packet to a process on the local machine that collects statistics on my traffic: snip My question is, should I be creating this socket for every request? OR would it be more "correct" to create it once on process startup and stash it in $r-pnotes or something? we have similar code in a mod_perl environment for sending Multicast UDP packets - I just store the socket filehandle in a global when it's created, and the next request can pick it up from there (just test if the global is defined). keeping the endpoint info in pnotes is only useful if you need write multiple UDP packets per request. -Simon And if I did that, would it work w/ TCP? Or unix pipes/sockets (which I *don't* understand) (btw the box is linux)? In testing, I'd prefer not to use TCP because it blocks if the count server is hung or down, vs UDP, where I just lose a couple of packets. TIA! L8r, Rob - Simon Rosenthal ([EMAIL PROTECTED]) Web Systems Architect Northern Light Technology One Athenaeum Street. Suite 1700, Cambridge, MA 02142 Phone: (617)621-5296 : URL: http://www.northernlight.com "Northern Light - Just what you've been searching for"
Socket/PIPE/Stream to long running process
So, in my mod_perl app, I run thru each request, then blast a UDP packet to a process on the local machine that collects statistics on my traffic: sub send_packet { my $r = shift; my $packet = shift; $r-warn("send_packet: No packet, not transmitting") if $debug !$packet; return unless $packet; $r-warn("Contents:\n$packethr") if $debug; $r-warn("send_packet: creating socket") if $debug; my $socket = new IO::Socket::INET ( PeerAddr = $r-dir_config('CountServer'), Proto= 'udp', ) or die "CountServer unable to create socket: $@\n"; $r-warn("send_packet: Sending to ", $r-dir_config('CountServer')) if $debug; # OK we have the correct buffer, lets send it out... unless ($socket-send($packet) == length $packet) { $r-warn( "send error on " . $socket-peerhost . ": $!" ); return SERVER_ERROR; #redir($r-dir_config('ErrorURL')); } $r-warn( "send_packet: send succesful") if $debug; } My question is, should I be creating this socket for every request? OR would it be more "correct" to create it once on process startup and stash it in $r-pnotes or something? And if I did that, would it work w/ TCP? Or unix pipes/sockets (which I *don't* understand) (btw the box is linux)? In testing, I'd prefer not to use TCP because it blocks if the count server is hung or down, vs UDP, where I just lose a couple of packets. TIA! L8r, Rob