Page 2 of 2 FirstFirst 12
Results 41 to 50 of 50

Thread: VB6 UniSock: winsock replacement [2008-08-14]

  1. #41
    Frenzied Member
    Join Date
    Dec 2007
    Posts
    1,072

    Re: VB6 UniSock: winsock replacement [2008-08-14]

    Hey Merri, could you help me out?

    Here's what I'm trying: http://www.pastie.org/private/qztzszs9mh7qvxsiwidmw
    Here's the output: http://www.pastie.org/private/k6ieb5in0j1uhgoc6tftia

  2. #42

    Thread Starter
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654

    Re: VB6 UniSock: winsock replacement [2008-08-14]

    Use the Connect event. Do not wait in a loop. Also, any continuous DoEvents is likely to break events, ie. by using DoEvents you may actually block the Winsock messages to the UniSock class.


    The current UniSock version is still a bit broken; I don't know when I have the fixed, hopefully 100% stable version out, so many things going on in my life atm.

  3. #43
    Frenzied Member
    Join Date
    Dec 2007
    Posts
    1,072

    Re: VB6 UniSock: winsock replacement [2008-08-14]

    I am trying to make a function like the following:

    Code:
    Public Function Request(ByRef Output As String, ReqType As String, URL As String, Optional Referer As String = vbNullString) As Boolean
    and call it like:
    Code:
    Dim HTML As String
    Request HTML, "GET", "http://www.google.com/"
    MsgBox HTML, , "Google's HTML"
    And I figured the best way to write that function is with a loop.

  4. #44

    Thread Starter
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654

    Re: VB6 UniSock: winsock replacement [2008-08-14]

    You have to make things event based. So this is how things should work:
    1. Request function is called. This returns True if success on starting a connection attempt. Request string is stored so that it can be accessed from any local function.
    2. Upon connection Connect event fires. The request string is sent.
    3. DataArrival event fires. It may fire multiple times for a single request, thus buffering is required. Data moves over the Internet in packets that are limited in size, this is why data may be split in multiple responses.
    4. Once all data is received, you may call a custom procedure to bring up the message box. You can also close the connection.
    Error event is likely to cancel the request.

    If you want to simplify things and you only need to download files, you can also check out UserControl's asynchronous download features. However, you still have to deal with events. Events are how VB6 works.

  5. #45
    Frenzied Member
    Join Date
    Dec 2007
    Posts
    1,072

    Re: VB6 UniSock: winsock replacement [2008-08-14]

    I know that the looping method will work with Winsock. (See attachment here: http://www.vbforums.com/attachment.p...1&d=1199419733)

    And I can't use a API or anything else to simply download the files... I need to store the cookies and such. It also needs to be as fast as possible, hence why I'm using Winsock (slow to write & open a file)

  6. #46

    Thread Starter
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654

    Re: VB6 UniSock: winsock replacement [2008-08-14]

    I have to recommend staying with the Winsock control. As far as I know DoEvents causes problems with anything in VB6 where VB code processes Windows window messages, thus you can't get that done with UniSock the way you want. For example if you add DoEvents to code executed by UniSock you'll get an instant crash (if I recall correctly).

  7. #47
    Frenzied Member
    Join Date
    Dec 2007
    Posts
    1,072

    Re: VB6 UniSock: winsock replacement [2008-08-14]

    Same thing will happen with cSocketMaster I assume?

  8. #48

    Thread Starter
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654

    Re: VB6 UniSock: winsock replacement [2008-08-14]

    UniSock's current version uses SelfCallback ASM thunk and creates a custom message window, which means all window messages are sent directly to VB6 code.

    CSocketMaster instead creates a STATIC window for messages and then subclasses this with a bit more specialized ASM thunk. I haven't tested whether this makes a difference with DoEvents; but I know the current UniSock implementation is more vulnerable to problems. This is why I've been converting CSocketMaster's ASM thunk for UniSock, but I still have a lot of work to do to get it all fully working. At the moment the code is able to create a single message window for all UniSock classes and subclass it for each and that part is stable, but all the other code is not adjusted yet.


    If you try CSocketMaster you should have a look at Vista issue and make sure you have a Vista/Windows 7 compatible version of it. There is also criticism to CSocketMaster over the forums/web which you may wish to search for to know what issues it has.

  9. #49
    Frenzied Member
    Join Date
    Dec 2007
    Posts
    1,072

    Re: VB6 UniSock: winsock replacement [2008-08-14]

    CSocketMaster worked fine for me. Thanks though. I'll keep UniSock saved

  10. #50
    Fanatic Member
    Join Date
    Aug 2007
    Posts
    912

    Re: VB6 UniSock: winsock replacement [2008-08-14]

    Hi All,
    I know this very old thread but still have a question
    Can i send the Unicode Data the the server?
    Im using the UniText control written by marry.
    Code:
    Private Sub WS_Connect()
      MsgBox "Unisock Connected " & WS.State
    Dim Url As String
    Dim StrTh As String
    
    StrTh = "GET " & "http://localhost/page.php?name=" & Text1.Text & "&email=" & Text2.Text & "&msg=" & UniText1.Text & vbCrLf
    MsgBox StrTh
    StrTh = StrTh & "HTTP/1.0" & vbCrLf
    StrTh = StrTh & "Accept: */*" & vbCrLf
    StrTh = StrTh & "Accept: text/html" & vbCrLf & vbCrLf
    StrTh = StrTh & "Content-Type: application/x-www-form-urlencoded" & vbCrLf
     
    WS.SendData StrTh
     
    MsgBox WS.State
    End Sub

Page 2 of 2 FirstFirst 12

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