pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Aidamir Lovpache <archibald@mastak.ru>
To: pgsql-interfaces@postgresql.org
Subject: Using socket operations in strored SPI procedures. What cause it?
Date: Wed, 12 Feb 2003 19:17:47 +0300
Message-ID: <20030212191747.29e3d380.archibald@mastak.ru> (raw)


	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



view thread (2+ messages)

Message-ID: <20030212191747.29e3d380.archibald@mastak.ru>
Permalink:  ../20030212191747.29e3d380.archibald@mastak.ru/
Also on:    postgresql.org/message-id/20030212191747.29e3d380.archibald@mastak.ru

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-interfaces@postgresql.org
  Cc: archibald@mastak.ru
  Subject: Re: Using socket operations in strored SPI procedures. What cause it?
  In-Reply-To: <20030212191747.29e3d380.archibald@mastak.ru>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox