Solved

Help For CAsyncSockt..?

Posted on 1998-06-16
2
159 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
Comment Utility
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
Comment Utility
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Host to IP 7 73
Separate into files by filename 12 66
Annoying "thing" blocks my view 4 49
Problem to event 3 47
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

763 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now