Solved

Help For CAsyncSockt..?

Posted on 1998-06-16
2
161 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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Suggested Solutions

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…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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 shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

831 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