|
-
May 16th, 2010, 10:11 AM
#41
Frenzied Member
Re: VB6 UniSock: winsock replacement [2008-08-14]
-
May 16th, 2010, 04:53 PM
#42
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.
-
May 16th, 2010, 08:57 PM
#43
Frenzied Member
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.
-
May 16th, 2010, 10:40 PM
#44
Re: VB6 UniSock: winsock replacement [2008-08-14]
You have to make things event based. So this is how things should work:- 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.
- Upon connection Connect event fires. The request string is sent.
- 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.
- 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.
-
May 16th, 2010, 10:54 PM
#45
Frenzied Member
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)
-
May 17th, 2010, 12:33 AM
#46
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).
-
May 17th, 2010, 08:46 AM
#47
Frenzied Member
Re: VB6 UniSock: winsock replacement [2008-08-14]
Same thing will happen with cSocketMaster I assume?
-
May 17th, 2010, 12:24 PM
#48
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.
-
May 18th, 2010, 11:29 PM
#49
Frenzied Member
Re: VB6 UniSock: winsock replacement [2008-08-14]
CSocketMaster worked fine for me. Thanks though. I'll keep UniSock saved
-
May 20th, 2010, 02:24 AM
#50
Fanatic Member
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|