Mark Atwood (fallenpegasus) wrote,
Mark Atwood

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: mysql

  • Razors

    I'm getting ads for I think five different "all metal" "get the best shave of your life" "throw away the plastic" razor startups. They all seem to be…

  • Doing what needs to be done

    On May 1st, one of my co-residents found one of the feral rabbits that live in the area cuddled up against a corner of the house. It was seriously…

  • The CTO of Visa, after listening to me present

    Some years ago, I was asked to travel to the corporate meeting center to present at a presentation-fest to the CxO staff of Visa. Yes, the one with…

  • Post a new comment


    Comments allowed for friends only

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded