?

Log in

No account? Create an account
entries friends calendar profile My Website Previous Previous Next Next
An idea for a MySQL UDF, connectionless UDP sendmsg - Mark Atwood
fallenpegasus
fallenpegasus
An idea for a MySQL UDF, connectionless UDP sendmsg
The gig I spent in New York, I spent writing a handful of MySQL UDFs. User Defined Functions are written in C, and link into the server binary, and are about as equally performant as the built in native functions.

The UDFs I wrote there take some parameters, marshall them in a way specific to that particular application, and then pass the packed data to the connectionless sendmsg() system call, sending it as a UDP/IP packet. The most interesting part of the actual development process for me was learning the new IPv6 friendly getaddrinfo() APIs.

But the problem solved seems generic enough, I've started a set of UDFs to solve this problem in a generic manner. Pass it a hostname, port number, and piece-of-data, and it will send that piece of data to that host's UDP port.

The only part of the design I'm sticking on, is I don't want to have to call getaddrinfo() every single time around the call loop if I don't have to, as it causes a memory alloc and dealloc each time, and might cause a DNS lookup.

Maybe I will design the function by polymorphic, and either take a hostname and port, or else take a packed struct addr and htoi portnum, and write another function to create the packed address chunk.

Tags:

Leave a comment