Boost logo

Boost Users :

Subject: [Boost-users] [ASIO] Async TCP/UDP server design help
From: Terry Lazoki (terry.lazoki_at_[hidden])
Date: 2013-12-28 21:43:25


I'm having hard time understanding the boost asio design and how i can use
it to tackle my problem.

My problem:
Designing a tcp/udp server that is time efficient.

1. User sends packet through tcp
2. Server receives packet and processes it to build a large tree (n > 20000)
3. Server then parses the new tree and sends a summary packet through udp
to another client

Conditions/Limitations:
 - Has to be time efficient, receiving, processing and sending has to be
done as fast as possible.
 - Processing the packet is heavy and can cause delays if its done in the
same thread
 - Parsing the tree is also a little heavy when sending it through udp, can
cause delays too

Design 1 (2 threads):
 Thread 1: ASIO TCP and UDP. TCP receives packets and adds it to a circular
buffer. While at the same time, processes the shared tree and sends packet
through udp.
 Thread 2: Server grabs packet from circular buffer and processes it

Some problems here:
 - I dont understand the async part here. What happens when tcp receives a
packet, if the current thread is continuously parsing the tree and sending
packets through udp. Do i need to separate the udp part to another thread?
 - I have 3 parts of the program that i need to run concurrently, well its
really 2 parts and receiving packets through tcp.

Any help is appreciated.

Thanks,



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net