ActiveX Socket

I am developing an activex control with a TCP/IP socket.
The activex control is written using vc++/mfc and the socket part is
using CAsyncSocket class support of MFC.
I am unable to connect to a server as I get WSAStartup not called
10093 error code.
This is due to the activex test container supporting the control
having a different process boundary.
The proposed solution seems (and please correct me if I am wrong) to
spawn a new thread from the activex control using afxbeginthread and
make a connection to the server from this thread.
Any comments on whether this will really work ?
0
12/13/2007 1:13:58 PM
vc.mfc 33608 articles. 0 followers. Follow

3 Replies
753 Views

Similar Articles

[PageSpeed] 2

"High Fiver" <highfiver.high@gmail.com> wrote in message 
news:9b0a32c4-d1ef-4420-9ee7-ea2bd1e49dda@b40g2000prf.googlegroups.com...
>I am developing an activex control with a TCP/IP socket.
> The activex control is written using vc++/mfc and the socket part is
> using CAsyncSocket class support of MFC.
> I am unable to connect to a server as I get WSAStartup not called
> 10093 error code.
> This is due to the activex test container supporting the control
> having a different process boundary.
> The proposed solution seems (and please correct me if I am wrong) to
> spawn a new thread from the activex control using afxbeginthread and
> make a connection to the server from this thread.
> Any comments on whether this will really work ?

Your idea of creating a thread and doing winsock communication within it is 
a good idea, since then you will not block the host app's primary thread and 
freeze the GUI if your Internet communication takes a long time.

ActiveX controls are usually running in the same process as the .exe.  So I 
think the test container app and the ActiveX control are the same process. 
Your ActiveX control has no way of knowing or affecting whether the host app 
(here, test container) calls WSAStartup or not, so your control is 
responsible for initializing and shutting down all required subsystems 
(here, Winsock).  I'm not sure if WSAStartup() affects the entire process, 
or just the calling thread.

-- David 


0
dc2983 (3206)
12/13/2007 1:28:43 PM
On Dec 13, 6:28 pm, "David Ching" <d...@remove-this.dcsoft.com> wrote:
> "High Fiver" <highfiver.h...@gmail.com> wrote in message
>
> news:9b0a32c4-d1ef-4420-9ee7-ea2bd1e49dda@b40g2000prf.googlegroups.com...
>
> >I am developing an activex control with a TCP/IP socket.
> > The activex control is written using vc++/mfc and the socket part is
> > using CAsyncSocket class support of MFC.
> > I am unable to connect to a server as I get WSAStartup not called
> > 10093 error code.
> > This is due to the activex test container supporting the control
> > having a different process boundary.
> > The proposed solution seems (and please correct me if I am wrong) to
> > spawn a new thread from the activex control using afxbeginthread and
> > make a connection to the server from this thread.
> > Any comments on whether this will really work ?
>
> Your idea of creating a thread and doing winsock communication within it is
> a good idea, since then you will not block the host app's primary thread and
> freeze the GUI if your Internet communication takes a long time.
>
> ActiveX controls are usually running in the same process as the .exe.  So I
> think the test container app and the ActiveX control are the same process.
> Your ActiveX control has no way of knowing or affecting whether the host app
> (here, test container) calls WSAStartup or not, so your control is
> responsible for initializing and shutting down all required subsystems
> (here, Winsock).  I'm not sure if WSAStartup() affects the entire process,
> or just the calling thread.
>
> -- David

But when i use a dialog based application i dont get any such errors.
Its got
to do something with an activex control. So, my question is that will
creating a new
thread and creating a socket in the new thread solve the activex
problem. I have tried
it doesn't work or maybe i am doing something wrong. Any help?
0
12/13/2007 2:02:16 PM
"High Fiver" <highfiver.high@gmail.com> wrote in message 
news:dab6fbf2-3261-4745-8bcf-bf66c0d88a01@s12g2000prg.googlegroups.com...
> But when i use a dialog based application i dont get any such errors.
> Its got
> to do something with an activex control. So, my question is that will
> creating a new
> thread and creating a socket in the new thread solve the activex
> problem. I have tried
> it doesn't work or maybe i am doing something wrong. Any help?

Did you try calling WSAStartup before calling any socket functions? This 
should work if the main thread has an MFC message pump.  If you want a new 
thread you can do that, which will definitely give you the required MFC 
message pump.  And a call to WSAStartup in the new thread before calling any 
socket functions.

-- 
Scott McPhillips [VC++ MVP] 

0
Scott
12/13/2007 2:43:41 PM
Reply:

Similar Artilces:

calls to unmanaged dll to create a socket result in debug assertio
I have an unmanaged C++ dll which is an MFC shared DLL that has functions in it to initialize sockets and do other ethernet related things. I have built a managed C++ wrapper project which is also an MFC shared DLL, compiled with /clr that calls functions in the unmanaged dll. Then I have a C# project which instantiates a member of the wrapper class to access the unmanaged functions. One of the functions in the unmanaged dll creates a new CAsyncSocket, checks to see if AfxSocketInit is successful, and if so, calls Create to create a new socket. When I call this function through my wra...

Activex #6
hi to all, i'm beginner in vc++,i don't know how to start activex in vc+ +.anyone help me from where i have to start studying. Thanks and Regards Muthukkumaran.S.A To begin with, why do you want ActiveX? Its older technology but it still has its usefulness. You want to make sure you really want it before jumping into it. MFC is older technology for ActiveX and it produces a larger module. ATL has smaller footprint and is the preferred choice. For tutorials, go to MSDN and codeguru/codeproject. -- Ajay <arumuthu@gmail.com> wrote in message news:f1bb07cb-4afe-4efb-9...

how to add a activeX control to a custom entity
I want to add a activeX control in a custom entity. It should be added of load of the form. So i am trying to write a onload javascript function which adds the axtiveX control. I new to MSCRM 3.0. Please direct me how to do this. It deppends on what you exactly want to do. But if it is just a control you might want to use an IFrame a create a simple html page which embeds the ActiveX control. -- Patrick Verbeeten (MCSD) Lead Developer Aviva IT Web: aviva-it.nl "Prakash N" wrote: > I want to add a activeX control in a custom entity. It should be added of > load of ...

ActiveX
Hi, I developed a ActiveX control. It has only a set of functions. No visible layouts. Its working fine when i tested using the Test Container and in VB. I need to use the control in VC. I developed a MFC EXE program. I added the control using Project>Add to Project menu item. It has been successfully added to the program. I've declared the activex variable in the View class. i'm able to invoke the functions in the ActiveX while coding(i.e. when writing code the list members quick help shows my functions in activex). It builds successfully. But while running the program it...

using external Com/ActiveX object
Hello, On VC++ 6.0 - How do I use Com/activeX objects ? Thanks :) Hello Coose Project ->Add to Projects-> components and Control and insert the ActiveX Controls With Regards R.Selvam Hello Coose Project ->Add to Projects-> components and Control and insert the ActiveX Controls With Regards R.Selvam "Eitan" <no_spam_please@nospam.com> wrote in message news:uBUvSx87DHA.3012@TK2MSFTNGP09.phx.gbl... > Hello, > On VC++ 6.0 - How do I use Com/activeX objects ? > > Thanks :) Another way to use com components (not just activex compo...

Register an ActiveX control with the Pocket PC 2003 Emulator
Hi, Is there anyone who knows how to register an Activex control with the Pocket PC 2003 Emulator? I successfully registered the control my PC using regsvr32. But when I inserted it in the application (a simple MFC dialog for enbedded devices), the main thread exit giving the following error. CoCreateInstance of OLE control {058E370E-6141-4E41-8B95-846EE04BB303} failed. >>> Result code: 0x80040154 >>> Is the control is properly registered? Warning: CreateDlgControls failed during dialog init. Can anyone help on this? Regds, Amila ...

ActiveX inside ActiveX
Hi All, Can I Include an ActiveX Control in my project which itself is an ActiveX Control. Thanks in Advance Regards Jayasankar ...

"Socket Not Found" AGAIN!
This is the second time this has happened. Our internet has gone down - 1st time for 5 days - 2nd time for 1 hour. When the internet comes back up - the stores can not talk to HQ. "Socket Not Found" is the message. I checked Firewalls, configuration...nothing has been change. I even ran a repair of HQ. Have absolutely no clue why this has happened. We have had no other other problems regarding connection after getting it up and running. Any ideas? Thanks and happy 4th! are you using Static IP addressing? "ZCSF" <ZCSF@discussions.microsoft.com> wrote in mess...

mfc activex
i used the mfc develop a activex control,and i did not add any code in it and make the activex control into the html.but when i closed the internet explore,one error was showed.Why? "chuangyl" <msnews.microsoft.com> wrote in message news:utMNIHn8GHA.4012@TK2MSFTNGP04.phx.gbl... > i used the mfc develop a activex control,and i did not add any code in it > and make the activex control into the html.but when i closed the internet > explore,one error was showed.Why? What does the error say? -- Ajay Kalra [MVP - VC++] ajaykalra@yahoo.com ...

unable to debug app with WMP activeX control
Hi I had an dialog application in VC 6.0, which had just one control, i.e windows media player activeX control. I upgraded the project to VC.NET 2003, now I can't debug the application when something is being played in windows media player. I get Protection error message like "debugger detected - please close it down and restart!...." This doesn't happen when nothing is being played in it. Is there any way to debug while playing something in it... Regards, Ashutosh ...

Activex #3
I have compiled my own activex file with VB 6.0 i wonder how can i hadd the .ocx file to the existing activeX list so I can display my control on the google desktop Bar ...

problems with creating activex control
Hi I don'y know what but something seems to be really strange in creating activeX control using MFC. First I create new ActiveX project using wizzard (with default settings). As I created new project, I reveal Class View Tree, go to LIB node and choose AddProperty. Then I Add few properties (with get/set methods), build - everything works fine, I can see everything in properties and I can access methods at run-time. Then I re-open project and add another property and build - this time property is visible in properies sheet but I can't access any of it's methods (get/set). A...

insert ActiveX into MFC without resource file
Hi, I try to insert ActiveX to my program as following: class MyWnd:public CFrameWnd { public: MyWnd() { CString strControlProgid; strControlProgid="mscal.calendar.7"; m_Control.DestroyWindow(); RECT rc; ::GetClientRect(m_hWnd,&rc); BOOL bStat=FALSE; bStat=m_Control.CreateControl(strControlProgid, "", WS_VISIBLE, rc, this, 5000, NULL, FALSE, NULL); if (bStat == FALSE) { ::MessageBox (m_hWnd,&...

Reading in floats and integers via socket
I received this spec from a vendor. They're sending these values via a socket (Delphi program; not using CArchive serialization) val0 name text null terminated val1 float (8 bytes) val2 int (8 bytes) val3 float (8 bytes) val4 int (4 bytes) val5 char (1 byte) What is the easiest way to get all of these values into their respective variables? I could read in the entire byte stream, and then convert the groupings of bytes to each respective variable, but there has to be an easier way than that! Can I use CSocket for something like this? But I don't see any methods like r...

ACTIVEX
in outlook 2003 when i go to type a new email message a box comes up that says Yours current security settings prohibit ActiveX controls on this page. As a result the page may not display correctly Does anyone know why this is and HOW i can get rid of it. i believe it has something to do with my signature. I get exactly the same problem and I've tried everything to cure it but no result. Can I add my voice to wanting an answer? Is there anyone out there who understands how to resolve thios? -- Cardo "csl" wrote: > in outlook 2003, > > when i go to type a new ...

regsiter activeX by programmation
Hello, I want to register some activex control by programmtion.What is the API to call ? If my memory serves me right I think I need DllRegisterServer but I am not sure and I cannot find a clear description of this method. Does it exist also for PocketPC ? Please Help You need to use LoadLibrary to load the DLL, then use GetProcAddress to find the DllRegisterServer function, and then call it. -- Jonathan Wood SoftCircuits http://www.softcircuits.com Available for consulting: http://www.softcircuits.com/jwood/resume.htm "mosfet" <tricubes@wanadoo.fr> wrote in message ne...

ActiveX control
I am wondering how to access the data chosen in a listbox control. I am guessing that the cell underlying the control does not automatically assume the value chosen in the control, so if I have another cell whose contents depend on the list item is it possible to 'read' and act upon that info with a regular Excel formula, or would it require some more heavy-duty VBA programming? There would also be many listbox controls that do not affect other cells (e.g., for displaying data only). After creating the first listbox for each field I would want to copy it and any related formulas...

Error message "The connection to the server has failed. Account: 'mail.xxxx.com', Server: 'mail.xxxx.com', Protocol: SMTP, Port: 25, Secure(SSL): No, Socket Error: 10060, Error Number: 0x800CCC0E"
When I setup the mail account, the account can send and receive email. BUT, when I setup the email account in home it cant send email, but it can receive email and show the following error message: "The connection to the server has failed. Account: 'mail.xxxx.com', Server: 'mail.xxxx.com', Protocol: SMTP, Port: 25, Secure(SSL): No, Socket Error: 10060, Error Number: 0x800CCC0E" What can I do? Brian Brian, It sounds like you have a firewall blocking port 25.try to telnet to a mail server out on the internet and see what happens. If your firewall is blocking ...

How to create ActiveX control without registering it first ?
Hi, Now I create my control like that : IMailPtr oSmtp = NULL; oSmtp.CreateInstance("AOSMTP.Mail"); or HRESULT hr = ::CoCreateInstance( CLSID_Mail, NULL, CLSCTX_ALL, IID_IMail, (LPVOID*)&pSmtp ); But I want to create ActiveX control directly from DLL without registering dll ( I need to create an application that doesn't need to be installed ). Is it possible ? Kamil > But I want to create ActiveX control directly from DLL without registering > dll Why? I...

activeX
Hi all, Does anyone know a ActiveX to be used in a Delphi application? The main requirement is to read the whole spreadsheet with its worksheets, because my Excel file has references among themselfs... (calculated fields...) I've found a set of ActiveX, but all of them just read the values and don't dealing with the calculated fields and their references... thanks for all... Marcos ...

Socket.BeginSend single threaded
Hello all, I'm using Socket.BeginSend. In my code, a stress situation may lead to several calls to BeginSend, before any completion callback has a chance to be executed. How can I make sure that, when the system will process the completion events, they will be serialized and use a single thread and will not be executed in parallel by several threads? --------- Thanks Sharon -- Thanks Sharon Sharon wrote: > Hello all, > > I'm using Socket.BeginSend. > In my code, a stress situation may lead to several calls to BeginSend, > before any complet...

ActiveX Control: Installation Fails
Hi, I am wondering if anyone can assist with a problem I am having with an ActiveX control failing to install on some occasions. My ActiveX control makes use of libcurl, which makes use of zlib1.dll I have been able to reproduce the problem of a failed installation by removing 'zlib1.dll' from my \windows\system32 directory. The ActiveX control is already packaged with this file however, and the .inf file contains: --------- .... [DefaultInstall] CopyFiles=install.files .... [install.files] zlib1.dll=zlib1.dll .... [DestinationDirs] install.files=11 --------- I even tried inclu...

connection to socket was unsuccessful: message timeout ???
hi, On a schedule time , a batch file is called to run (Task Scheduler) to connect the VPN connection (10 mins prior to store connection) though the schedule works but when it comes to HQclient this messagekeep on popping... 1) connection to socket was unsuccessful: message timeout My best guess is that VPN was not established the connection ??? Prior to connection time that's why it is giving me this error message. Am I correct ??? If not, can someone tell me where this error is triggered ? Thanks For some reason, HQ Client will give me that error if the VPN is open before the c...

Not able to create an Activex control within another activex contr
Hi, I'm not able to create an Activex control within another activex control. ........... CAxCtrl m_obj; ................. m_obj.Create(NULL,_T("Control1"),WS_CHILD | WS_VISIBLE,CRect(0,0,100,50),this,1000); ( this ----> parent activex control) I'm getting an error in occcont.cpp , in this particular line TRY { m_pCtrlCont = afxOccManager->CreateContainer(this); } END_TRY Thanks ...

ActiveX can't create Object problem
Hello, I have a service built in VB that uses an excel activeX compoenet to create excel reports from data reported to it from MSSQL by fireing stored procedures. For some reason right now the service keeps reporting that it cannot create the ActiveX object. Has anyone seen this problem and what could be the cause. Shawn ...