Re: Winsock Cryptic Error :|
Which line generates the error? Most of us are too old for our telepathy to work.
Re: Winsock Cryptic Error :|
Quote:
Originally Posted by Al42
Which line generates the error? Most of us are too old for our telepathy to work.
If I knew that - I wouldn't have such a problem. The error is a winsock error and is not 'generated' by any one particular line of code as far as I can see.
This is the problem, I need a second pair of eyes to find where the problem may be.
Re: Winsock Cryptic Error :|
Hi,
Ok for the first problem
Ur function Url(addloc) = "http://www.google.co.uk" should return
www.google.co.uk and not the Http:// that is what is generating the error, I think due to the fact that Winsock does not know that u are using HTTP Protocol to communicate, and does not know how to handle the remote to be http://www.google.co.uk, but is fine when you only pass it www.google.co.uk as
Code:
mkt.Protocol = sckTCPProtocol
mkt.RemoteHost = "www.google.co.uk"
mkt.RemotePort = 80
mkt.Connect
Maybe trying something different might help, here is how you can use MSXML to do the same thing. Even though you can use this for XML data, but it can be used for normal HTTP operations also.
P.S. you can run it in both sync and async see MSDN for both complete examples.
Code:
Dim myHTTP
Dim HTTPUrl As String
Dim HTTPData As String
HTTPUrl = "http://www.google.com"
Set myHTTP = CreateObject("Msxml2.XMLHTTP")
myHTTP.Open "GET", HTTPUrl, False
myHTTP.setRequestHeader "Cache-Control", "no-cache"
myHTTP.setRequestHeader "Accept-Language", "it"
myHTTP.setRequestHeader "Content-type", "application/x-www-form-urlencoded"
myHTTP.Send
On Error Resume Next
If Err.Number <> 0 Then
HTTPData = "Bad URL"
Else
HTTPData = myHTTP.responsetext
End If
Set myHTTP = Nothing
Debug.Print HTTPData
Hope this helps, also to post the data, its the same.
Code:
Dim SendData
Dim myHTTP
Dim HTTPUrl As String
Dim HTTPData As String
HTTPUrl = "http://www.google.com"
Set myHTTP = CreateObject("Msxml2.XMLHTTP")
myHTTP.Open "POST", HTTPUrl, False
myHTTP.setRequestHeader "Cache-Control", "no-cache"
myHTTP.setRequestHeader "Accept-Language", "it"
myHTTP.setRequestHeader "Content-type", "application/x-www-form-urlencoded"
myHTTP.Send SendData
On Error Resume Next
If Err.Number <> 0 Then
HTTPData = "Bad URL"
Else
HTTPData = myHTTP.responsetext
End If
Set myHTTP = Nothing
Debug.Print HTTPData