Results 1 to 4 of 4

Thread: ActiveX DLL's and the winsock component

  1. #1

    Thread Starter
    Member
    Join Date
    Oct 1999
    Location
    Richmond, Virginia
    Posts
    41

    Post

    I am starting to experiment with creating my own activex components for use in my websites ASP pages.

    I would like my new component to be able to send and receive information with other servers using Microsoft's WINSOCK control.

    How could I accomplish this? I have tried

    Winsock1 = Server.CreateObject("MSWinsockLib.Winsock")

    but for some reason the object is not created successfully. How would I accomplish this? How would I take advantage of the controls events (DataArrival etc)? Thanks for your assistance.

    TheLeeMan

    [This message has been edited by TheLeeMan (edited 01-25-2000).]

  2. #2
    Guest

    Post

    Add a reference to the mswinsck.ocx.

    And in the general declaration section use:
    private withevents sckTest as MSwinsockLib.Winsock

    Example:
    Code:
    Option Explicit
    Private WithEvents sckTest As Winsock
    
    Private Sub Class_Initialize()
        Set sckTest = New MSWinsockLib.Winsock
    End Sub
    
    Private Sub sckTest_DataArrival(ByVal bytesTotal As Long)
    
    End Sub

    ------------------

    Vincent van den Braken
    EMail: [email protected]
    ICQ: 15440110
    Homepage: http://www.azzmodan.demon.nl




  3. #3
    New Member
    Join Date
    Mar 2000
    Posts
    2
    AzzModan,

    I have posted some code on this site (new posting) based on the code sample you gave here.

    Could you have a look at the code and see whats wrong ? Somehow the winsock control events are not raised I guess...thats why I can connect but there is no data received. Do you have any comments abouts something Im missing ?
    Here is the code again...

    Option Explicit

    'Private objWERSSocket As New MSWinsockLib.Winsock
    Private WithEvents objWERSSocket As MSWinsockLib.Winsock

    Public sDump As String
    Private sDataBack As String


    Public Function ConnectToWERS() As Boolean
    Dim sRequestHeader As String
    Dim sRequestURL As String
    Dim sURL As String
    Dim blnRetValue As Boolean


    objWERSSocket.Protocol = sckTCPProtocol
    objWERSSocket.RemoteHost = "sdowning"
    objWERSSocket.RemotePort = 80

    Call objWERSSocket.Connect

    While objWERSSocket.State <> 7
    MsgBox "Before " & objWERSSocket.State
    DoEvents
    Wend

    MsgBox "After " & objWERSSocket.State

    sRequestHeader = "GET /livelink/livelink.exe?func=Personal.Tasks HTTP/1.0" & Chr(10)
    sRequestHeader = sRequestHeader & "Content-type: application/x-www-form-urlencoded" & Chr(10)
    sRequestHeader = sRequestHeader & "Content-length: " & Len(sRequestURL) & Chr(10) & Chr(10)
    sURL = sRequestHeader

    MsgBox sURL
    Call objWERSSocket.SendData(sURL)

    End Function

    Private Sub Class_Terminate()
    MsgBox objWERSSocket.BytesReceived
    Set objWERSSocket = Nothing
    End Sub

    Private Sub objWERSSocket_DataArrival(ByVal bytesTotal As Long)

    Call objWERSSocket.GetData(sDataBack, vbString)

    'sDump = sDump & sDataBack
    End Sub

    Private Sub Class_Initialize()
    Set objWERSSocket = New MSWinsockLib.Winsock
    End Sub

  4. #4
    New Member
    Join Date
    Jun 2000
    Location
    South Africa, Centurion
    Posts
    8
    I am having the same problems, one thing I have learned is that the control acts funny when you set the remote port and remote host before calling the connect method. Rather do it all in one like:

    objWERSSocket.Protocol = sckTCPProtocol
    objWERSSocket.Connect "sdowning", 80

    The events are still a nuisance to me, if you get that working, please let me know.

    Cheers
    Wolfie



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