Skip site navigation (1) Skip section navigation (2)

Using socket operations in strored SPI procedures. What cause it?

From: Aidamir Lovpache <archibald(at)mastak(dot)ru>
To: pgsql-interfaces(at)postgresql(dot)org
Subject: Using socket operations in strored SPI procedures. What cause it?
Date: 2003-02-12 16:17:47
Message-ID: 20030212191747.29e3d380.archibald@mastak.ru (view raw or flat)
Thread:
Lists: pgsql-interfaces
	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(at)mastak(dot)ru

pgsql-interfaces by date

Next:From: Ulf RehmannDate: 2003-02-12 21:02:26
Subject: postgresql 7.3 versus 7.2
Previous:From: David WheelerDate: 2003-02-12 15:51:03
Subject: Re: Prepare and prepare ?

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group