Re: berkley sockets

Поиск
Список
Период
Сортировка
От J S B
Тема Re: berkley sockets
Дата
Msg-id a47902760609131740o51e146ceq73e3fd1b13f9741a@mail.gmail.com
обсуждение исходный текст
Ответ на Re: berkley sockets  (Tony Caduto <tony_caduto@amsoftwaredesign.com>)
Ответы Re: berkley sockets  (Martijn van Oosterhout <kleptog@svana.org>)
Список pgsql-general
Thanks alot Tony.
just wondering if the same can be done with C
~Jas

 
On 9/13/06, Tony Caduto <tony_caduto@amsoftwaredesign.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


В списке pgsql-general по дате отправления:

Предыдущее
От: ljb
Дата:
Сообщение: Re: remote duplicate rows
Следующее
От: Ron Johnson
Дата:
Сообщение: Re: remote duplicate rows