CAyncSocket like class design problem

Hi,

I am trying to write a wrapper class for Winsock SOCKET to use it in a
non-mfc project. When I checked MFC CAyncSocket class code, I found
that it provides a number of overridables like OnAccept, OnConnect,
OnSend etc. But in the winsock documentation, I can=92t find any
messages corresponding to these events. While analyzing the call stack
of OnAccept, I found that a message with id 883(I think it=92s
WM_SOCKET_NOTIFY) is received by an object of class CSocketWnd. From
the parameters of this message a CAyncSocket is constructed and
provided the override functionality.

Is the WinSock SOCKET associated with any window? I couldn=92t find any
window handle in socket creation APIs. How MFC makes this possible?

When I=92m designing the class how easily can I develop these concepts?

Another strange thing, I can=92t find any proper documentation
WM_SOCKET_NOTIFY message. Is it an undocumented message?

Regards,
Faisal M.
0
faisalm83 (35)
12/1/2008 12:58:25 PM
vc.mfc 33608 articles. 0 followers. Follow

2 Replies
938 Views

Similar Articles

[PageSpeed] 42

Code for CAsyncSocket includes a hidden window where messages are routed.

The code is available in MFC source so you should examine that

Faisal wrote:
> Hi,
> 
> I am trying to write a wrapper class for Winsock SOCKET to use it in a
> non-mfc project. When I checked MFC CAyncSocket class code, I found
> that it provides a number of overridables like OnAccept, OnConnect,
> OnSend etc. But in the winsock documentation, I can�t find any
> messages corresponding to these events. While analyzing the call stack
> of OnAccept, I found that a message with id 883(I think it�s
> WM_SOCKET_NOTIFY) is received by an object of class CSocketWnd. From
> the parameters of this message a CAyncSocket is constructed and
> provided the override functionality.
> 
> Is the WinSock SOCKET associated with any window? I couldn�t find any
> window handle in socket creation APIs. How MFC makes this possible?
> 
> When I�m designing the class how easily can I develop these concepts?
> 
> Another strange thing, I can�t find any proper documentation
> WM_SOCKET_NOTIFY message. Is it an undocumented message?
> 
> Regards,
> Faisal M.
0
12/1/2008 6:22:37 PM
There are no messages.  CAsyncSocket uses the WSAAsyncSelect call, which takes the ID of a
message that is posted to a specified window.  Thus, the thread that is running must be in
a UI thread context so it has a functioning message pump.  Read about WSAAsyncSelect. This
is the key to creating the interaction.

The handlers are virtual methods of what can be thought of as an abstract superclass
(CAsyncSocket).  You derive from CAsyncSocket and override the various virtual methods you
want.  The base code looks up the SOCKET handle in a table, retrieves a pointer to what it
calls a CASyncSocket object (it is your derived subclass) and calls the virtual method,
which of course calls your virtual method.
					joe

On Mon, 1 Dec 2008 04:58:25 -0800 (PST), Faisal <faisalm83@gmail.com> wrote:

>Hi,
>
>I am trying to write a wrapper class for Winsock SOCKET to use it in a
>non-mfc project. When I checked MFC CAyncSocket class code, I found
>that it provides a number of overridables like OnAccept, OnConnect,
>OnSend etc. But in the winsock documentation, I can�t find any
>messages corresponding to these events. While analyzing the call stack
>of OnAccept, I found that a message with id 883(I think it�s
>WM_SOCKET_NOTIFY) is received by an object of class CSocketWnd. From
>the parameters of this message a CAyncSocket is constructed and
>provided the override functionality.
>
>Is the WinSock SOCKET associated with any window? I couldn�t find any
>window handle in socket creation APIs. How MFC makes this possible?
>
>When I�m designing the class how easily can I develop these concepts?
>
>Another strange thing, I can�t find any proper documentation
>WM_SOCKET_NOTIFY message. Is it an undocumented message?
>
>Regards,
>Faisal M.
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15972)
12/1/2008 6:43:17 PM
Reply:

Similar Artilces:

SMTP Mail Sending Problem Windows 7
Hi, I am using SMTPClient class for sending mail from my C# application. I have successfully sent mail in local area or outside of the domain. But, i met a strange problem. When i send the mail to the client who uses Windows 7 he cannot receive the mail, although exchange server tells me "it has delivered". I worked on it and i found a silly case. When i set MailPriority.High the client receives the mail. If i do not set the mail priority to high, the client does not receive the mail. Can Anyone tell me what is the problem, or has anybody met a problem as simi...

Classes gone from class list
Why might some of my classes dissappear from the Class View in VS2005? I am also getting error 2079 for some classes that were fine half an hour ago and still exist in the Class View window. The header and cpp files for the missing and broken classes are included in my project. Everything was fine until about half an hour ago - I added 1 pure virtual operation to a base class and a concrete method to 9 subclasses, (I think this is irrelevant!) and half of the classes are now missing and I can't use the others. The method was called SortList() and calls a list sort operation specifi...

Sorting numbers acts like text sort
We have a worksheet (Excel 2000) that was e-mailed to us. When we open it, it says there are macros, which there aren't. No matter if we say "Disable" or "Enable" macros, all cells are formatted to "General", and when sorting, the numbers 10000, 7102, 1169 sort as: 10000, 1169, 7102. We can try to format as number, but to no avail. Sorting still isn't right. Have seen this many times before, but don't know how to resolve. Can you help? Thanks. Never mind. Sorry to waste your time. Saw two suggestions below on this page. Missed them the first ...

Problems sending emails
I'm running windows xp and using outlook 2000 for emails. Suddenly about 10 days ago emails that I sent stopped arriving at their destination. I can use the internet and receive emails using the same ISP account. Emails leave the outbox, but never arrive. I've tried sending emails to myself with no luck. I've double checked all the email settings with the ISP's techno dept and all is fine. I've done a system restore to a time when I know that emails worked, still no luck. Emails don't always get sent easily. Sometimes it takes 3 or 4 attempts and sometimes I get a 554...

Transfer out from Offline Inventory Problem
I face a strange problem, when the offline items transferred out from the offline inventory to another store they stay appearing in the offline inventory with their quantities, and a transfer out number appear in front of them. when I generated the item movement report I didn't find the serial is transferred out, but I found the transfer number mentioned in the offline inventory and the same item code in it. by this problem the offline quantities increasing dramatically and the transferred out quantities didn't deducted from it. Note: when I open the transfer out mentioned in the...

KeyBindings like Word.
Hello, I would like to use KeyBindings in Excel like we have in Word. My purpose is creating a shortcut (e.g Ctrl+J) for a command in Excel (e.g FormatCondition). In other word, each time I will press Ctrl+J i will run the FormatCondition dialog will appear. Is there any way to do it ? With thanks, Moshe I believe you need to create a macro that shows that dialog, and attach your shortcut key to the macro. The macro needs just a single line Sub ShowCFDialog() Application.Dialogs(xlDialogConditionalFormatting).Show End Sub Then in Tools/Macro/Macros, select this macro, click ...

Can't access invoice designer
Recently when trying to access invoice designer in Money 2004 Small Business I get "Unexpected Error" window and an "OK" button to acknowlege it. Reinstalled money and service pack. Still not working. Now what? Did you remove or just reinstall? I would suggest removing and then reinstall to a different folder as a start. "Oh oh!" <anonymous@discussions.microsoft.com> wrote in message news:9c0301c478c8$e989a1c0$a501280a@phx.gbl... > Recently when trying to access invoice designer in Money > 2004 Small Business I get "Unexpected Error"...

Hyperlink problems
I am running Excel 2007. I have a spreadsheet that I have hyperlinks to .BMP files. I have my computer setting to use MS Picture Viewer as default program, but when I click the link from within Excel it uses MS Paint to open the file. How can I set it to be MS Picture Viewer? 1. Open Folder Options in Control Panel. 2. Select "File Types" tab. 3. Select BMP from "Extensions" and press "Advanced" button. 4. Select "Open" from "Actions" and press "Edit" button. 5. Type Picture Viewer pass or select Picture Viewer exe file (o...

hyperlink problems
Sometimes I create one email... copy it and paste it into new emails.. and when it's pasted I always get this same problem.. Here is an example of the error wlmailhtml:{1CCDD8F0-9573-4BA1-A7CD-5578123C3193}mid://00000068/!x-usc:http://www.jlfood.com/ When what it should just be a link to www.jlfood.com The original email is fine... it's just when copied and pasted it changes.. ...

Ive tried it and I dont like it- Mikey can have it
I purchased money 05 and tried it for about 3 months. I dont care for it at all. How can I convert my 05 file back to 04 use? You can't. See http://umpmfaq.info/faqdb.php?q=17. "braunsteven" <braunsteven@discussions.microsoft.com> wrote in message news:D37FD95E-2140-4672-8247-46847080BDB6@microsoft.com... >I purchased money 05 and tried it for about 3 months. I dont care for it at > all. How can I convert my 05 file back to 04 use? BTW, what did Mikey do to make you want to wish it on him???? "braunsteven" <braunsteven@discussions.microsoft.com&g...

Need to design a signout form
Alright here is my problem. I have a database of my office's field supplies in Access. I want to design a form for people who are checking out and checking in items. For example an employee would click on something and have JUST the form with 2 tabs show up, one tab for singing in and one for out show up. Does anyone know how to have it setup so that just a form opens and not the whole database? Can't do it. However, here is a link to code that will allow you to manipulate the Access Application window so your form will appear to float on the desktop: http://www.mvps.org/access/...

Remove "Private" designation
I just marked a message as "Private" and now I cannot edit it. I would like to go back and change it to public. This is a calendar on the network that many people have access to and all items can be considered public. I believe I am the owner of the calendar and even set myself up with "owner" properties and I cannot edit the appointment. Any suggestions? Thanks, Linda ...

VBA-Ho how to change order of designs in the collection
Hi everybody, PP 2007 I have two templates in my PP. I used the following code to change the thier order in the collection ActivePresentation.Designs(2).MoveTo 1 but this code doesn't work. Any suggestions how I can change this order. I In other words when you click on layout dropdown it shows the first templates with its associated layout and then shows next template with its layout and ... I want to switch those twmplates position( first goes to second postion and second goes to the first postion) -- Best regards, Edward The code seems to work to move the master bu...

Sorting Problem #5
Thanks Rita. That helps except for one thing. I get a "This operatio requires the merged cells to be identically sized" is there any wa around this? Thanks Jor -- riderfa ----------------------------------------------------------------------- riderfan's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=1560 View this thread: http://www.excelforum.com/showthread.php?threadid=27154 ...

Pub 2000 Problem
I have been using MSPub 2000 for years and have never had any problem until now. When I click on the icon, or the mspub.exe file in Explorer, I get a message "MSPub 2000 vers. 6 has encountered a problem and needs to close". Then program closes. I have uninstalled and re-installed Office 2000, Small Business Edition. But this still happens. Curiously, if I go to a .pub file in Explorer and click on it, the program opens fine and I can edit the old document. I can also then open other pub files. I can create a new publication if I use the Wizard or choose a template, BUT I cannot cre...

MFC class wizard and IDISPATCH
Hello In ATL projects wizard give us a chance to add class with Idispatch(Dual). In MFC add class wizard, there is an option for Automation but this cause to add dispintarface. Also activex control projects add interfaces with dispintarface which means user can only use late-binding. Mayeb this may performance problems. I am not sure? Is there a special reason to doesn't have an option for dual interface in MFC project wizards..? If we want to use dual interfaces in ou project, what must we do? Just manual edit? Thanks.. I think that if you want a more "COM-centric" ap...

EMKAi- looking for a Graphic Designer/Brand Manager
This is a multi-part message in MIME format. ------=_NextPart_000_0009_01CAF16D.07864610 Content-Type: multipart/alternative; boundary="----=_NextPart_001_000A_01CAF16D.07864610" ------=_NextPart_001_000A_01CAF16D.07864610 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable EMKAi ------=_NextPart_001_000A_01CAF16D.07864610 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HT...

Problem with XML-Validation
I have got an XML file, that aderes to a XDR-Schema which references elements and attributes in two other XDR-Schemas. I want to validate this XML file before I create a DOM tree in C#. This works fine for every namespace except of the default namespace. In the default namespace there is no Event when the XML file is wrong. Could anybody tell me what there is wrong with my code (as seen below)? I have tried several things, but I could not make the validation work properly. The class simply creates a DOM form a XML file and writes every error out in the console. Best regards, Daniel Haag pu...

DateAdd problem
i want to calculate and end date for a lease term pretty easy =DateAdd("yyyy",+[Term],[StartDate]) so my start date is 01/07/09 and my term is 1 year so my end date is 01/07/10 trouble is, what it should be is 30/06/10 my question is how do i get the above formula to deduct one day to get the correct date? -- deb =DateAdd("yyyy",+[Term],[StartDate]) - 1 -- Allen Browne - Microsoft MVP. Perth, Western Australia Tips for Access users - http://allenbrowne.com/tips.html Reply to group, rather than allenbrowne at mvps dot org. "deb" ...

Asynchronous uploading problem with FtpWebRequest
dear friends I have to write a program of multiple upload of images. I have used the concept of Asynchronous through net. But It is giving error. Here first I am using single image file upload. when it reaches to this line response = (FtpWebResponse)state.Request.EndGetResponse(ar); It is written in function EndGetResponseCallback then it is giving error The remote server returned an error: (550) File unavailable (e.g., file not found, no access). please help me it is very urgent. I am showing my whole code using System; using System.Collections.Generic; using Syst...

Explorer Problem
Whenever I open Explorer, it generally opens another window on it's own that takes me to some ad site or news site. When i use the search function, whatever link I click on gets redirected to someother site. I've tried the security fixes through Microsoft and they only partially remove whatever bug is in the system. Anyone have an idea where to find these bugs and how to remove them? <lol> Your computer is infected by adware. --- Leonard Grey Errare humanum est Blackstream wrote: > Whenever I open Explorer, it generally opens another window on it's own t...

Problem with references in Graphs
Hi everyone, Okay, lets see if somebody can help me with this. I have my little graphics with some nameranges references: ie:name ='Data-Daily'!F1 y values= 'Data-Daily'!Yvalues x values= 'Data-Daily'!Xvalues Now, the problem comes when I delete Data-Daily (because I want to refresh the data or just any reason. My graph is too smart and the references become #REF# because of course the sheet doesn't exist anymore. I have tried to use manual calculation and CALCULATE on the VBA code to solve this. But even if the graph stays now the same, the references are...

OWA 2003 - Mozilla, Netscape, Firefox
Any fix or OWA 2003 Netscape/Mozilla/Firefox faq would be appreciated My OWA 2003 logoff button doesn't work properly: Mozilla & Netscape (prompts the user for an ID and password and then displays Access Denied) Firefox 1.0 no prompt, goes to the logoff page but displays the Close button, which doesn't do anything when you hit it Either way I see it frustrating MANY users. Internet Explorer works fine (natch.) OWA is officially supporting IE and some Netscape versions only. Regards, Boris "Jonathan Reiser" <guppy413@junk.hotmail.com> wrote in message news:...

form problems
I have a main form with a subform. The subform is in datasheet view. Basically what I am trying to prevent is a user from submitting their information when one of the fields in the subform has a certain value (call it aaa for ease). So, if they hit submit and the field that I am trying to not let have aaa in it has it, they won't be able to move on. The problem I am having is that it easy to test this for the last record inputted in the datasheet, but not for previous ones (e.g. if they had entered two or more records in the subform). So, I have been trying to play around with the ...

how do I use MFC data member from a concrete C++ class from a COM interface
Hello I have created a new thread because the subject is somewhat different. I use a C# asp.net webbapplication which call different COM object using the defined COM interface for each concrete C++ class. So at the bottom I have a OpenDS method located in the concrete C++ class CHandle_DS. This method is also define at the IHandle_DS COM interface. Here is the sequence for my new design for the new concrete C++ object 1. I create a concrete C++ class from C# asp.net like this CHande_DS handle_ds = new Handle_DS(); This works perfect. 2. I call OpenDS like this handle_ds.OpenDS(); ...