MSVC++6.0 - Socket Programming

Posted on 2000-03-30
Last Modified: 2008-02-26
I have written a CClientSocket class (based on the CAsyncSocket class) which I'm trying to use for socket communications.  The CClientSocket object overrides the OnReceive, OnConnect, etc events.  I would like to know how to notify my main program that the OnReceive event (and others) have fired.  Is there a nice, neat way of doing this, or do I need to send, perhaps, a custom message to my program?

Question by:mgonyea
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

Accepted Solution

ShaunWilde earned 150 total points
ID: 2670470
In my opinion you are on the right track. If I need to tell the app anything I either call a method of the app object or usually I tell it via a user message (or even thread message).

Other people may have something more elegant and I hope to see such a response to your message.

Expert Comment

ID: 2670676
One little thing to add:
If your socket is running in different thread, better post a thread message then calling a method of the main object.
More thread safely...

Author Comment

ID: 2670712
I will probably use Message posting on the server side(s) of the socket, but the client program creates only one socket.  I'm just in the middle of implementing an inline function that might do the trick.


Expert Comment

ID: 2735926
if u are using CAsyncSocket  then there is no need to make threads.
i normally keep my sockets stack inside document and views are informed on certain events.

Expert Comment

ID: 2838282
> More thread safely...

If you wish to achieve thread safety you can use Critical Sections and Mutexes etc however this is inly realy useful when setting and getting data and not where the CSocket methods are concerned

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

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

691 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