Re: berkley sockets

From: "J S B" <jsbali(at)gmail(dot)com>
To: "Tony Caduto" <tony_caduto(at)amsoftwaredesign(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: berkley sockets
Date: 2006-09-14 00:40:24
Message-ID: a47902760609131740o51e146ceq73e3fd1b13f9741a@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Thanks alot Tony.
just wondering if the same can be done with C
~Jas

On 9/13/06, Tony Caduto <tony_caduto(at)amsoftwaredesign(dot)com> wrote:
>
> 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
>
>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message David Link 2006-09-14 01:46:37 oracle listener intercept
Previous Message ljb 2006-09-14 00:36:39 Re: remote duplicate rows