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
Printable View
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
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.
I am trying to make a function like the following:
and call it like:Code:Public Function Request(ByRef Output As String, ReqType As String, URL As String, Optional Referer As String = vbNullString) As Boolean
And I figured the best way to write that function is with a loop.Code:Dim HTML As String
Request HTML, "GET", "http://www.google.com/"
MsgBox HTML, , "Google's HTML"
You have to make things event based. So this is how things should work:Error event is likely to cancel the request.
- 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.
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.
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)
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).
Same thing will happen with cSocketMaster I assume?
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.
CSocketMaster worked fine for me. Thanks though. I'll keep UniSock saved :D
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