On Thu, 18 Oct 2007 10:55:19 -0400 "Billow Gao" <[EMAIL PROTECTED]> wrote: > Is it possible to write a dynamic loaded C function as an UDP or TCP server? > > What we want to do it is: > Add a search function which send a UDP package to remote UDP server > and then listen to an UDP port, waiting for the result. > Ideally, we don't close the UDP server after the search query end. > So we can reuse it for next search. > > Is it possible?
>Short answer: yes. Slightly longer answer: If you need to ask this >quetion then you should really talk to someone about network >programming but this is the wrong list. Thanks for your reply. I can write the network program. But I am not 100% sure whether I can add the c-language function ( http://www.postgresql.org/docs/8.2/interactive/xfunc-c.html) to PostgreSQL. The function will be dynamic loaded by PostgreSQL. I want to know whether there are any limitation on the function I wrote. for example: If I want to write a function: PG_FUNCTION_INFO_V1(c_talktoremoteudp); And use it in PostgreSQL like: ========================================= SELECT name, c_talktoremoteudp (emp, 1500) AS overpaid FROM emp WHERE name = 'Bill' OR name = 'Sam'; ========================================= The function c_talktoremoteudp will: 1. send udp data to remote udp server 2. monitor an udp port and wait for the reply 3. return the data to the select query. Anyway, I guess that it can be done. I will write a simple function to test it. Ying >If you are asking if PostgreSQL already does UDP then the answer is >no. You need to write a server program that talks UDP in one direction >and TCP to PostgreSQL in the other direction. Watch out for security >issues.