Solved

MSVC++6.0 - Socket Programming

Posted on 2000-03-30
5
321 Views
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?

Thanks.
0
Comment
Question by:mgonyea
[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
5 Comments
 
LVL 9

Accepted Solution

by:
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.
0
 
LVL 1

Expert Comment

by:alechko
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...
0
 
LVL 1

Author Comment

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

Thanks....brb.
0
 

Expert Comment

by:daknight2000
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.
0
 
LVL 9

Expert Comment

by:ShaunWilde
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
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

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