⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 basmodule.bas

📁 TEST.C是在ARM的Web Server源文件
💻 BAS
字号:
Attribute VB_Name = "basModule"
'QQ群:10988210
'老人家
'QQ:1504839
'TEST.C是在ARM的Web Server源文件,现在用VB实现,用来分析TCPIP。

Option Explicit




Public Function GetWinsockState(state As Integer) As String
    Select Case state
        Case sckClosed
            GetWinsockState = "Closed"
        Case sckOpen
            GetWinsockState = "Open"
        Case sckListening
            GetWinsockState = "Listening"
        Case sckConnectionPending
            GetWinsockState = "Connection pending"
        Case sckResolvingHost
            GetWinsockState = "Resolving host"
        Case sckHostResolved
            GetWinsockState = "Host resolved"
        Case sckConnecting
            GetWinsockState = "Connecting"
        Case sckConnected
            GetWinsockState = "Connected"
        Case sckClosing
            GetWinsockState = "Peer is closing the connection"
        Case sckError
            GetWinsockState = "Error"
    End Select
End Function









Function funGetTxtPack(strGetTxt As String) As String       ' 1. "GET /"与" HTTP/1.1"之间的文件名“GET /223.bmp HTTP/1.1”
    Dim intLocFont  As Integer
    Dim intLocBack  As Integer
    
    intLocFont = InStr(1, strGetTxt, "GET /")
    intLocBack = InStr(1, strGetTxt, " HTTP/1.1")
    
    funGetTxtPack = Mid(strGetTxt, intLocFont + 5, intLocBack - intLocFont - 5)
    
End Function




'要完成下面函数
Function funHeadTxtPack(strGetTxt As String) As String      ' 2."Head /"
    funHeadTxtPack = "Head /"
End Function




Function funPostTxtPack(strGetTxt As String) As String      ' 3."Post /"
    funPostTxtPack = "Post /"
End Function





Function funDeleteTxtPack(strGetTxt As String) As String    ' 4."Delete /"
    funDeleteTxtPack = "Delete /"
End Function





Function funOptionsTxtPack(strGetTxt As String) As String   ' 5."Options /"
    funOptionsTxtPack = "Options /"
End Function





Function funTraceTxtPack(strGetTxt As String) As String     ' 6."Trace /"
    funTraceTxtPack = "Trace /"
End Function





Function funPutTxtPack(strGetTxt As String) As String       ' 7."Put /"
    funPutTxtPack = "Put /"
End Function





Function subStrToByt(strTemp As String) As Variant
    Dim intFor      As Integer
    ReDim RetByt(Len_Byte(strTemp) - 1) As Byte
    For intFor = 1 To Len_Byte(strTemp)
        RetByt(intFor - 1) = (Mid_Byte(strTemp, intFor, 1))
    Next
    subStrToByt = RetByt
End Function





'计算出字符长度,注意1个中文为2个字节
Public Function Len_Byte(sString As String) As Integer
    Len_Byte = LenB(StrConv(sString, vbFromUnicode))
End Function





'在字符串sString中,从开始位置iStart取iLen个长度的字符,注意1个中文为2个字节
Public Function Mid_Byte(sString As String, iStart As Integer, iLen As Integer) As Byte
    Dim sStrByte
    sStrByte = MidB(StrConv(sString, vbFromUnicode), iStart, iLen)
    Debug.Print AscB(sStrByte)
    Mid_Byte = AscB(sStrByte) ' StrConv(sStrByte, vbUnicode)
End Function






'HTTP协议状态码的含义
'号码    含义
'-----------------------------------------
'"100" : Continue
'"101" : witching Protocols
'"200" : OK
'"201" : Created
'"202" : Accepted
'"203" : Non-Authoritative Information
'"204" : No Content
'"205" : Reset Content
'"206" : Partial Content
'"300" : Multiple Choices
'"301" : Moved Permanently
'"302" : Found
'"303" : See Other
'"304" : Not Modified
'"305" : Use Proxy
'"307" : Temporary Redirect
'"400" : Bad Request
'"401" : Unauthorized
'"402" : Payment Required
'"403" : Forbidden
'"404" : Not Found
'"405" : Method Not Allowed
'"406" : Not Acceptable
'"407" : Proxy Authentication Required
'"408" : Request Time-out
'"409" : Conflict
'"410" : Gone
'"411" : Length Required
'"412" : Precondition Failed
'"413" : Request Entity Too Large
'"414" : Request-URI Too Large
'"415" : Unsupported Media Type
'"416" : Requested range not satisfiable
'"417" : Expectation Failed
'"500" : Internal Server Error
'"501" : Not Implemented
'"502" : Bad Gateway
'"503" : Service Unavailable
'"504" : Gateway Time-out
'"505" : HTTP Version not supported
'客户方错误( 1 x x ) 4 0 2 需要付费
'1 0 0 继续4 0 3 禁止
'1 0 1 交换协议4 0 4 未找到
'成功( 2 x x ) 4 0 5 方法不允许
'2 0 0 O K 4 0 6 不接受
'2 0 1 已创建4 0 7 需要代理认证
'2 0 2 接收4 0 8 请求超时
'2 0 3 非认证信息4 0 9 冲突
'2 0 4 无内容4 1 0 失败
'2 0 5 重置内容4 11 需要长度
'2 0 6 部分内容4 1 2 条件失败
'重定向( 3 x x ) 4 1 3 请求实体太大
'3 0 0 多路选择4 1 4 请求U R I太长
'3 0 1 永久转移4 1 5 不支持媒体类型
'3 0 2 暂时转移服务器错误
'3 0 3 参见其他5 0 0 服务器内部错误
'3 0 4 未修改5 0 1 未实现
'3 0 5 使用代理5 0 2 网关失败
'客户方错误( 4 x x ) 5

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -