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
shorttime 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