Re: Please Help!!! - CAsyncSocket::OnReceive Not Working for Microsoft UDP Application (msocudp)
- From: "Scott McPhillips [MVP]" <org-dot-mvps-at-scottmcp>
- Date: Mon, 19 May 2008 22:57:18 -0400
"Roshan" <roshan@xxxxxxxxxxxx> wrote in message news:8da3087e-5c1e-4633-b70a-94c533136fb7@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Scott,
Hello. Hope you're weekend went well. I am now trying threading with
UDP sockets. On my first try it seems
the OnReceive() is not getting invoked when sending a packet in a
thread.
Please let me know what I might be doing wrong here.
Snippets of my code:
The code can be pretty much thrown away. It seems to have been written without studying the CAsyncSocket documentation or examples at all. You must create the socket in the same thread that you want to receive and send from. There are MFC examples that illustrate this. You must use a UI type of MFC thread. There are MFC examples that illustrate this. And, your thread code only works if you receive the expected 10 packets. UDP IS NOT RELIABLE. You can not and must not assume that you will receive all the packets. And finally, what is the point of suspending your main thread until the socket thread completes? This is fundamentally wrong in any Windows program: It will lock up your window.
I am not optimistic that you can complete this assignment, and if you must rely on UDP to give you all the packets then it is an impossible assignment :(
--
Scott McPhillips [VC++ MVP]
.
- Follow-Ups:
- References:
- Please Help!!! - CAsyncSocket::OnReceive Not Working for Microsoft UDP Application (msocudp)
- From: Roshan
- Re: Please Help!!! - CAsyncSocket::OnReceive Not Working for Microsoft UDP Application (msocudp)
- From: Scott McPhillips [MVP]
- Re: Please Help!!! - CAsyncSocket::OnReceive Not Working for Microsoft UDP Application (msocudp)
- From: Roshan
- Re: Please Help!!! - CAsyncSocket::OnReceive Not Working for Microsoft UDP Application (msocudp)
- From: Scott McPhillips [MVP]
- Re: Please Help!!! - CAsyncSocket::OnReceive Not Working for Microsoft UDP Application (msocudp)
- From: Roshan
- Please Help!!! - CAsyncSocket::OnReceive Not Working for Microsoft UDP Application (msocudp)
- Prev by Date: Re: Please Help!!! - CAsyncSocket::OnReceive Not Working for Microsoft UDP Application (msocudp)
- Next by Date: Re: string class and UNICODE?
- Previous by thread: Re: Please Help!!! - CAsyncSocket::OnReceive Not Working for Microsoft UDP Application (msocudp)
- Next by thread: Re: Please Help!!! - CAsyncSocket::OnReceive Not Working for Microsoft UDP Application (msocudp)
- Index(es):
Relevant Pages
|