Listening UDP or switch to TCP in a MFC application
Posted
by
Alexander.S
on Stack Overflow
See other posts from Stack Overflow
or by Alexander.S
Published on 2012-10-20T08:42:20Z
Indexed on
2012/11/19
11:05 UTC
Read the original article
Hit count: 198
I'm editing a legacy MFC application, and I have to add some basic network functionalities. The operating side has to receive a simple instruction (numbers 1,2,3,4...) and do something based on that. The clients wants the latency to be as fast as possible, so naturally I decided to use datagrams (UDP).
But reading all sorts of resources left me bugged. I cannot listen to UDP sockets (CAsyncSocket
) in MFC, it's only possible to call Receive which blocks and waits. Blocking the UI isn't really a smart. So I guess I could use some threading technique, but since I'm not all that experienced with MFC how should that be implemented?
The other part of the question is should I do this, or revert to TCP, considering reliability and implementation issues. I know that UDP is unreliable, but just how unreliable is it really? I read that it is up to 50% faster, which is a lot for me.
References I used: http://msdn.microsoft.com/en-us/library/09dd1ycd(v=vs.80).aspx
© Stack Overflow or respective owner