Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

CSocket and worker thread

Posted on 2003-11-27
6
Medium Priority
?
701 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 600 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
Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

 
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 600 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
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.
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

715 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