Hi Randy,

On Wed, Aug 17, 2016 at 4:01 PM, Randy Abernethy
<randy.aberne...@gmail.com> wrote:
> Would be nice to have a UDP Transport! Have you wired it into the cross
> tests? That IDL is sort of the benchmark for interop higher up the stack

I haven't yet wired it into the cross tests, or done anything aside
from a fairly simple hello test (see below). Actually, when I run
"make check" on the master branch in thrift, most of the tests fail
anyway, which is a bit worrisome.

Please feel free to test out the code and report any hiccups to the
ML. Actually, if anyone would like to further integrate UDP tests into
the testing code in thrift, that would be much appreciated.

Thanks!

C

// https://willwarren.com/2012/01/24/creating-a-public-api-with-apache-thrift/

namespace cpp hello

enum HelloLanguage {
        ENGLISH,
        FRENCH,
        SPANISH
}

service Hello {
        string say_hello(),
        string say_foreign_hello(1: HelloLanguage language),
        list<string> say_hello_repeat(1: i32 times),
}

My test class (actually I'm using gtest) has the following two
methods, which should be helpful. Note, that if running unit tests,
since the UDP socket is not connected, the client port and server port
should be different. However, in practise, on separate machines, they
would typically be the same for a P2P topology.

boost::shared_ptr<TSimpleServer> HelloUdpSocketBinaryTest::makeServer() {
        return boost::make_shared<TSimpleServer>(

boost::make_shared<HelloProcessor>(boost::make_shared<HelloHandler>()),
                boost::shared_ptr<TServerSocket>( (TServerSocket *)
new TUdpServerSocket( server_port, client_port ) ),
                boost::make_shared<TTransportFactory>(),
                boost::make_shared<TBinaryProtocolFactory>()
        );
}

boost::shared_ptr<TTransport> HelloUdpSocketBinaryTest::makeTransport() {
        return boost::make_shared<TBufferedTransport>(
                boost::shared_ptr<TSocket>( new TUdpSocket( host,
server_port, client_port ) )
        );
}

Reply via email to