Results 1 to 6 of 6

Thread: [RESOLVED] Do I need to use Winsock API in ActiveX DLL?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Apr 2001
    Location
    oxford, UK
    Posts
    149

    Resolved [RESOLVED] Do I need to use Winsock API in ActiveX DLL?

    Hi

    I have a VB ActiveX dll app running on ourwebserver. We have a customer that needs to have an XML doc sent to their platform.

    Currently they have an app that uses the Winsock control to SendData to their IPAddress using specific Port no. I presume they have a winsock listening on that port at the other end? or coudl they have something else?

    I understand how the winsock CONTROL works. However I dont know what is the best way to implement this requirement to send XML doc to their platform as I presume you cannot add a Winsock control to ActiveX DLL (as there is no user interface forms). Do I have to use the Winsock API (I'm not not keen on this as it looks time consuming)? I am familiar with using the XMLHTTP object to POST data. Is this the same concept? Or do I have to stick to Winsock as this is what is listening on the client server?

    Many thanks
    Kester

  2. #2
    Lively Member BradBrening's Avatar
    Join Date
    Oct 2001
    Location
    Gillespie, IL
    Posts
    102

    Re: Do I need to use Winsock API in ActiveX DLL?

    I have used the Winsock control in and ActiveX DLL many times. Within your DLL project, simply add a form, call it "frmDummy". Then, place your Winsock control on the form. Then you can use the following code in within your main class:

    VB Code:
    1. Private WithEvents oSock As Winsock
    2.  
    3. Private Sub Class_Initialize()
    4.     Set oSock = frmDummy.Winsock1
    5. End Sub
    6.  
    7. Private Sub Class_Terminate()
    8.     Set oSock = Nothing
    9. End Sub

    With this code you can use the Winsock control in your DLL just like you would in any other project.

    As to whether this is the best route, it depends. Is the remote machine listening on port 80? Is it expecting an HTTP transaction? If the communication is going to be over HTTP on port 80, then your best bet would probably be to use MSXML since you are already familiar with it.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Apr 2001
    Location
    oxford, UK
    Posts
    149

    Re: Do I need to use Winsock API in ActiveX DLL?

    Thanks for your reply.

    I am a bit puzzled as I thought the point of ActiveX dll was that they had no UI and therefore you cannot add a form to the project. However I will investigate further.

    I wish I could use the MSXML obj but the customer currently has a Winsock listening on a particular port so I guess this is the only option I have?

    Thanks
    Kester

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Apr 2001
    Location
    oxford, UK
    Posts
    149

    Re: Do I need to use Winsock API in ActiveX DLL?

    Oh OK if I remove 'Unattended execution' from the project properties then I can add the form!

    What are the implications of removing 'Unattended execution' - just need to ensure that I dont use any Messages boxes? Would unhandled errors cause msgboxes?

  5. #5
    Lively Member BradBrening's Avatar
    Join Date
    Oct 2001
    Location
    Gillespie, IL
    Posts
    102

    Re: Do I need to use Winsock API in ActiveX DLL?

    I know that when I am testing DLLs that I've created like this I have seen an error dialog. Usually though, especially when dealing with network operations, I have very strong error handling built into the code. So, by the time I've taken the DLL to the production stage there isn't any place an unhandled error can occur.

    But, to anwer your question, removing the "Unattended Execution" option would mean that unhandled errors would display an error dialog.
    Last edited by BradBrening; Oct 14th, 2005 at 09:22 AM.

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Apr 2001
    Location
    oxford, UK
    Posts
    149

    Re: Do I need to use Winsock API in ActiveX DLL?

    That seems to do it nicely!

    Thx for the help.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width