From: | Tony Caduto <tony_caduto(at)amsoftwaredesign(dot)com> |
---|---|
To: | J S B <jsbali(at)gmail(dot)com>, pgsql-general(at)postgresql(dot)org |
Subject: | Re: berkley sockets |
Date: | 2006-09-13 21:15:02 |
Message-ID: | 450874D6.3090706@amsoftwaredesign.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
J S B wrote:
> I don't want to connect to the postgres database.
>
> The scenario is something like this.
>
> Postgres database has to initiate some deamon process running is
> another server.
> The only way i could think of doing this was openeing a socket
> connection between postgres database and
> the deamon process through a shared object dynamicall loaded in postgres.
>
> Berkley sockets is the socket API in unix that uses
> <sys/socket.h>
>
> Don't know if there's a better way to do it.
>
> ~Jas
>
I have done this using PLperl (untrusted) and it works just fine.
Here is a simple example that just sends a command to a popup
notification daemon I use.
Win32 clients connect to the daemon and when I need to notify them of
incoming files from a ProFTP server I use this function.
Works great and have never had a problem.
CREATE or REPLACE FUNCTION public.psendpopup(
text,
text)
RETURNS pg_catalog.varchar AS
$BODY$
use IO::Socket;
$sock = new IO::Socket::INET (
PeerAddr => 'localhost',
PeerPort => '13000',
Proto => 'tcp',
);
die "Could not create socket: $!\n" unless $sock;
print $sock "null\r\n";
print $sock "send_broadcast\r\n";
print $sock $_[0]."\r\n";
print $sock $_[1]."\r\n";
close($sock);
$BODY$
LANGUAGE 'plperlu' VOLATILE;
--
Tony Caduto
AM Software Design
http://www.amsoftwaredesign.com
Home of PG Lightning Admin for Postgresql
Your best bet for Postgresql Administration
From | Date | Subject | |
---|---|---|---|
Next Message | Steve Crawford | 2006-09-13 21:50:16 | Re: Kill specific connection |
Previous Message | Tom Lane | 2006-09-13 21:01:34 | Re: Kill specific connection |