Solved

Help For CAsyncSockt..?

Posted on 1998-06-16
2
162 Views
Last Modified: 2013-11-20
Anybody can tell you how to use CAsyncSockt in Non-Blocking mode..? If Possible any sample code also..The doubt is how to use the notification messages.

Thanx In Advance
Sanesh
0
Comment
Question by:sanesh
  • 2
2 Comments
 
LVL 32

Accepted Solution

by:
jhance earned 100 total points
ID: 1317997
It's pretty simple:

1) Derive your own class from CAsyncSocket, say myAsyncSocket so that you can override the OnXXX functions to receive the notification messages. Do this by using the ClassWizard, Add new class dialog.  Be sure to select CAsyncSocket as the base class.

2) Add an instance of myAsyncsocket to your application.

3) Using the ClassWizard in VC++, add the message maps for the notifications you want to receive.

4) Implement your OnXXX functions.  It seems the biggest confusion is about OnSend.  It notifies that it is OK to send data, NOT that the data has been sent.

0
 
LVL 32

Expert Comment

by:jhance
ID: 1317998
Oops, I forgot to include:

Call IOCtl(FIONBIO, &dwNoblock); (with dwNoblock a DWORD != 0)
to make the socket non-blocking, then call

AsyncSelect() to enable the notifications you want to receive.  

Remember to set the lEvent paramter in Create to 0 so that you can call IOCtl on the object.
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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

Suggested Solutions

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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.

828 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