Hey Christopher Thanks for sharing -Jake
On Wed, Aug 17, 2016 at 3:30 PM, Christopher Friedt <chrisfri...@gmail.com> wrote: > Hi folks, > > I'm working on a couple of transports on my GitHub fork of Thrift [1]. > > There is a UDP Transport ( TUdpSocket, TUdpServerSocket ) > implementation in "feature/udp-sockets" [2]. > > It's still in development, but Works For Me™, so far. For a quick > comparison, see [3]. > > Some notes: > > * Rather than lumping functionality in the base class (TSocket), I > opted to not modify that, and instead added new functionality in > TUdpSocket. This duplicates some code, but it's probably better to do > that than to introduce unnecessary complexity in a base class. > * Rather than using TSocket::getSocketInfo(), I added my own function > to stringify socket addresses that seems more appropriate according to > RFC3986. My function is called TUdpSocket::sockaddrToString(). > * Remnants of UDP messages tend to be discarded if the entire message > is not read in one go (at least on my machine). Therefore, I buffer > the entire UDP message when it is first read. This causes some > inconsistencies with the rest of Thrift which expect to be able to > read fragments of a message a few bytes at a time. Poll(2) would fail > on subsequent TSocket::read()s), which is why I shadowed it in > TUdpSocket::read() in such an unusual way. > * I factored-out TGetAddrInfoWrapper into it's own .cpp / .h files, for > reuse. > * I factored-out cast_sockopt into it's own header file, for reuse. > * Probably some unnecessary modifications ( private -> protected > fields ) in TServerSocket.h > * Made recv() and send() virtual in TSocket > > If anyone is interested in testing, feedback is welcome. Please put my > email in the CC, if you do. I'd be happy to work on getting this code > upstreamed when things are a bit less busy. > > Thanks, > > C > > [1] https://github.com/cfriedt/thrift > [2] https://github.com/cfriedt/thrift/tree/feature/udp-sockets > [3] https://goo.gl/qjCSni >