Solved

MSVC++6.0 - Socket Programming

Posted on 2000-03-30
5
319 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
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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
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.

776 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