X-Original-To: pgsql-interfaces@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 74B44474E5C for ; Wed, 12 Feb 2003 11:00:42 -0500 (EST) Received: from host21.mastak.com (host21.mastak.com [217.106.234.11]) by postgresql.org (Postfix) with ESMTP id 9134F474E44 for ; Wed, 12 Feb 2003 11:00:41 -0500 (EST) Received: from www.mastak.ru (www.mastak.ru [217.106.234.193]) by host21.mastak.com (Postfix) with ESMTP id 997B6C173 for ; Wed, 12 Feb 2003 19:00:31 +0300 (MSK) Received: from archi.office.hopgo.com (archi.office.hopgo.com [213.248.12.72]) (authenticated (0 bits) as archibald) by www.mastak.ru (8.11.4/8.11.4) with ESMTP id h1CFxJe18020 for ; Wed, 12 Feb 2003 18:59:19 +0300 Date: Wed, 12 Feb 2003 19:17:47 +0300 From: Aidamir Lovpache To: pgsql-interfaces@postgresql.org Subject: Using socket operations in strored SPI procedures. What cause it? Message-Id: <20030212191747.29e3d380.archibald@mastak.ru> Organization: mastak.ru X-Mailer: Sylpheed version 0.8.4 (GTK+ 1.2.10; i686-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200302/31 X-Sequence-Number: 3652 I use SPI strored procedures for sending broadcasts through sockets by sendto function. If you have such experience, please tell me what problem can cause it, if it could block the postmaster process for short time or some other problems unknown for me. I still have't noticed any problems yet. Here are the code i use for sending UDP broadcasts: int ret; int fd = socket( PF_INET, SOCK_DGRAM , 0); extern int errno; struct sockaddr_in myaddr; int t=1; setsockopt(fd, SOL_SOCKET, SO_BROADCAST, &t, sizeof(int)); if ( fd < 0 ) elog(NOTICE,"setsockopt() %s\n", strerror(errno)); inet_aton(BROADCAST,&myaddr.sin_addr); myaddr.sin_family=AF_INET; myaddr.sin_port=htons(BIND_PORT); ret = sendto(fd, p, len , 0, (struct sockaddr * ) &myaddr, sizeof(struct sockaddr_in)); if ( ret < 0 ) elog(NOTICE,"sendto() %s\n", strerror(errno)); else elog( NOTICE,"%d bytes was sent to FE.\n",ret ); close(fd); (Aidamir Lovpache) Archibald. mailto:archibald@mastak.ru