Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
0
Help us understand the problem. What is going on with this article?
@ohisama@github

vbsの作法 その44

More than 1 year has passed since last update.

概要

vbsの作法調べてみた。
winsock使ってみる。
生httpを見たかった。

写真

image

環境

windows7 64bit

サンプルコード

Dim oWin
Dim sURL
Dim sPage
Dim sServer
Dim nPort
Dim sBuffer
Dim sSource
Dim bClose
Dim App6
Dim Appflg

Sub App6_exit()
    Appflg = 2
End Sub

Sub App6_ok()
    sServer = "www.ostrosoft.com"
    sPage = "/"
    Set oWin = CreateObject("OSWINSCK.Winsock")
    WScript.ConnectObject oWin, "soc_"
    oWin.Connect CStr(sServer), CLng(nPort)
    While Not bClose
        WScript.Sleep 100
    Wend
End Sub

Sub soc_OnClose()
    oWin.CloseWinsock
    App6.text = sSource
    bClose = True
    Set oWin = Nothing
End Sub

Sub soc_OnConnect()
    oWin.SendData "GET " & sPage & " HTTP/1.0" & vbCrLf & vbCrLf
End Sub

Sub soc_OnDataArrival(ByVal bytesTotal)
    oWin.GetData sBuffer
    sSource = sSource & sBuffer
End Sub

Sub soc_OnError(ByVal Number, Description, ByVal Scode, ByVal Source, ByVal HelpFile, ByVal HelpContext, CancelDisplay)
    Msgbox Number & ": " & Description
    oWin.CloseWinsock
End Sub

Set App6 = Createobject("OHIcompo6.srv")
WScript.ConnectObject App6, "App6_"
App6.text = ""
sURL = ""
sPage = ""
sServer = ""
nPort = 80
sBuffer = ""
sSource = ""
bClose = False
sProxy = ""
Do
    WScript.Sleep(100)
    App6.ping
Loop until Appflg = 2
Set App6 = Nothing



以上。

0
Help us understand the problem. What is going on with this article?
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away

Comments

No comments
Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account Login
0
Help us understand the problem. What is going on with this article?