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

  • Meme: Life Experience Quiz

    The Life Experience Test Overall, you have partaken in 97 out of 174 possible life experiences. Your average life experience score is…

  • Portrait Meme

    Portrait Meme Originally uploaded by FallenPegasusInstructions: * Take a picture of yourself right now. Don't change your clothes, don't fix…

  • Privilage?

    Based on an exercise developed by Will Barratt, Meagan Cahill, Angie Carlen, Minnette Huck, Drew Lurker, Stacy Ploskonka at Illinois State…

  • 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