|
Frequently
Asked Questions
(and
some that are not so frequently asked)
Q:
I want to use some of the Winsock API calls, where do I get the
socket value?
A:
When a dsSocket control is connected or listening the Socket property
contains the handle of the underlying TCP/IP socket. This can be
used as required in an API call to affect the socket connection.
Q:
I can manage to do an HTTP GET command with dsSocket, what about
a POST?
A:
There aren't a lot of headers you need to worry about when you use
the GET command but doing a POST is a little more involved. It all
comes down to what you need to send to the Web server once you get
connected.
Here's a code snippet that will send a POST command to an ASP script
on a server. It assumes that you have already made the connection
to the server.
myData$ = "POST /scripts/Search.asp HTTP/1.1" & vbCrLf & _
"Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*" & vbCrLf & _
"Referer: http://alton/GreenLine/Symbol_Search/Green_Line_Symbol_Search.html" & vbCrLf & _
"Accept-Language: en-us" & vbCrLf & _
"Content-Type: application/x-www-form-urlencoded" & vbCrLf & _
"Accept-Encoding: gzip, deflate" & vbCrLf & _
"User-Agent: Mozilla/4.0 (compatible; MSIE 4.0; Windows NT)" & vbCrLf & _
"Host: " & vbCrLf & _
"Content-Length: 72" & vbCrLf & _
"Connection: Keep-Alive" & vbCrLf & _
vbCrLf & _
"Symbol=t&SymbolMethod=%27&Name=toronto+dominion&NameMethod=%27&Market=CA" & vbCrLf & _
vbCrLf
dsSocket1.Send = myData$
Some
notes: Substitute real information between the <>'s for the Host,
Content-Length is the number of bytes in the parameters being posted
(starts with Symbol in code above) and doesn't include the CrLf.
Q:
My Web server needs Basic Authentication for an HTTP request. How
do I send this?
A:
You need to encode the username and password using Base64 and then
add the HTTP header that sends the authentication information. The
header looks like:
Authorization: Basic VXNlck5hbWU6cGFzc3dvcmQ=
where
the encoded string in this case is equal to "UserName:password"
(without the quotes) and has been encoded using Base64.
Have
a question that you need answered? Contact our support group by
sending an email message to support@dolphinsys.com
|