Boost logo

Boost Users :

Subject: Re: [Boost-users] [ASIO] Async TCP/UDP server design help
From: Dirk Botha (bothadj_at_[hidden])
Date: 2014-01-02 05:33:41


Hi Terry,

I might have solved your problem for you already.

Try taking a look at: http://github.com/TheLastCylon/kisscpp

Documentations, such as it is, is available here:
http://thelastcylon.github.io/kisscpp/index.html

Currently, there is no UDP support, but I'm sure it won't take much to get
that in.
Feel free to ask questions, if you want.

--
Regards,
Dirk J. Botha
http://www.djb.co.za
~*~ Registered Linux User #379726 ~*~
"If people concentrated on the really important things of life, there'd be
a shortage of fishing poles." ~ Doug Larson
On 30 December 2013 08:41, U.Mutlu <for-gmane_at_[hidden]> wrote:
> Terry Lazoki wrote, On 12/29/2013 03:43 AM:
>
>  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,
>>
>
>
> I would use a modular approach using an acceptor, a shared job queue,
> and multiple worker threads (at least 2 workers; depends on the job
> characteristics, duration etc.). Of course a synchronisation/locking
> is needed for shared resource access/usage,
> see for example https://en.wikipedia.org/wiki/Producer%96consumer_problem
>
> --
> U.Mutlu
> DACOS Notdienstanlagen GmbH, Germany, www.dacos.de
>
>
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users


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