Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

MSVC++6.0 - Socket Programming

Posted on 2000-03-30
5
Medium Priority
?
324 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 450 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

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
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.

916 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