Документация о Winsock Control :
http://msdn.microsoft.com/en-us/library/aa228119%28v=vs.60%29.aspx
Пример здесь:
http://support.microsoft.com/kb/163999/en-us
Мой короткий пример с обработкой событий в VBscript:
Dim sock
Set sock = WScript.CreateObject("MSWinsock.Winsock","sock_")
sock.RemoteHost = "www.yandex.com"
sock.RemotePort = "80"
sock.Connect
Dim received
received = 0
Sub sock_Connect()
WScript.Echo "[sock] Connection Successful!"
sock.SendData "GET / HTTP/1.1"& vbCrLf & "Host: " & sock.RemoteHost & vbCrLf & vbCrLf
End Sub
Sub sock_Close()
WScript.Echo "[sock] Connection closed!"
End Sub
Sub sock_DataArrival(Byval b)
Dim data
sock.GetData data, vbString
received = received + b
WScript.Echo "---------------------------------------"
WScript.Echo " Bytes received: " & b & " ( Total: " & received & " )"
WScript.Echo "---------------------------------------"
WScript.Echo data
End Sub
'Wait for server close connection
Do While sock.State <> 8
rem WScript.Echo sock.State
WScript.Sleep 1000
Loop
Вывод будет:
cscript /nologo sockhttp.vbs
[sock] Connection Successful!
-------------------------------
Bytes received: 1376 ( Total: 1376 )
-------------------------------
HTTP/1.1 200 Ok
Date: Mon, 08 Dec 2014 15:41:36 GMT
Content-Type: text/html; charset=UTF-8
Cache-Control: no-cache,no-store,max-age=0,must-revalidate
Expires: Mon, 08 Dec 2014 15:41:36 GMT
...