Solved

CSocket and worker thread

Posted on 2003-11-27
6
690 Views
Last Modified: 2013-11-20
I create CSocket (damn it) in worker thread. It fails to function. I found in one of questions
http://www.experts-exchange.com/Programming/Programming_Languages/MFC/Q_10299360.html
that it's because worker thread does not have message loop and as one of remedies recommends adding message loop to worker thread.
My question is
1. Does it really help by adding message loop (here I think meant message queue?)
2. If it solves CSocket mystery, how Do I add message queue to worker thread
0
Comment
Question by:amakalski
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 

Author Comment

by:amakalski
ID: 9834437
...and after adding message queue to my worker thread Do I need to pick any messages from the queue? (I don't really want to pick any messages, the msg queue I only need to accomodate CSocket appetite).
0
 
LVL 12

Assisted Solution

by:migel
migel earned 200 total points
ID: 9835560
Hi!
What reason in using ASync sockets in the WORKER thread????
May be you can use sync. sockets?
0
 

Author Comment

by:amakalski
ID: 9838185
No, I use CSocket which is sync. socket I mean it blocks when I call Receive.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 12

Expert Comment

by:migel
ID: 9838256
But it is normal :-)
since you call receive in the working thread then UI will not freeze.
Or you need add timeout support?
0
 
LVL 4

Accepted Solution

by:
inox earned 200 total points
ID: 9838310

CSocket (damn it!!) is designed to be used in mainthread preventing the need to do multithreading.
This doesn't mean that it can't be used in treads but its a bit obscure to do so.

Its not very much difficult to use the Windows Socket API instead of CSocket MFC but it depends on what's to do

It's somewhat extensive to outline both, do you think you can choose one solution?
- singlethreaded with CSocket
- multithreaded with CSocket
- multithreaded with Socket API
0
 

Author Comment

by:amakalski
ID: 9838431
Oh, well,
I will give up CSocket at all. Recently I digged up some of my old code and found wrapper classes around Winsock API. These classes will help me to get rid of MFC CSocket and have another advantage - less MFC dependency !

P.S Thanks everybody, I will split points
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
repeatSeparator  java  challenge 13 59
Expand data scrubbing tool 13 36
How to determine file rename from EventLog ? 2 62
sumHeights  challenge 17 83
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question