作品 - 小工具 - 通讯测试

通讯测试

本文最后更新时间:2009/03/18

简单的网络协议通讯测试工具,如果您对此工具感兴趣,请看下面源码:

  1. VERSION 5.00  
  2. Object = "{248DD890-BB45-11CF-9ABC-0080C7E7B78D}#1.0#0""MSWINSCK.OCX" 
  3. Begin VB.Form frmTest   
  4.    BorderStyle     =   3  'Fixed Dialog  
  5.    Caption         =   "通讯测试" 
  6.    ClientHeight    =   6000  
  7.    ClientLeft      =   6180  
  8.    ClientTop       =   1995  
  9.    ClientWidth     =   5220  
  10.    LinkTopic       =   "Form1" 
  11.    MaxButton       =   0   'False  
  12.    MinButton       =   0   'False  
  13.    ScaleHeight     =   6000  
  14.    ScaleWidth      =   5220  
  15.    Begin VB.CommandButton cmdClose   
  16.       Caption         =   "关闭(&C)" 
  17.       Height          =   345  
  18.       Left            =   2310  
  19.       TabIndex        =   5  
  20.       Top             =   5610  
  21.       Width           =   795  
  22.    End 
  23.    Begin VB.TextBox txtPort   
  24.       Height          =   375  
  25.       Left            =   1590  
  26.       TabIndex        =   4  
  27.       Text            =   "80" 
  28.       Top             =   5580  
  29.       Width           =   615  
  30.    End 
  31.    Begin VB.TextBox txtIP   
  32.       Height          =   345  
  33.       Left            =   90  
  34.       TabIndex        =   3  
  35.       Text            =   "127.0.0.1" 
  36.       Top             =   5580  
  37.       Width           =   1425  
  38.    End 
  39.    Begin VB.CommandButton cmdSend   
  40.       Caption         =   "发送(&S)" 
  41.       Height          =   345  
  42.       Left            =   3990  
  43.       TabIndex        =   0  
  44.       Top             =   5580  
  45.       Width           =   1155  
  46.    End 
  47.    Begin VB.TextBox txtCommand   
  48.       Height          =   1695  
  49.       Left            =   90  
  50.       MultiLine       =   -1  'True  
  51.       ScrollBars      =   2  'Vertical  
  52.       TabIndex        =   2  
  53.       Text            =   "frmTest.frx":0000  
  54.       Top             =   3810  
  55.       Width           =   5055  
  56.    End 
  57.    Begin VB.TextBox txtInfo   
  58.       Height          =   3615  
  59.       Left            =   60  
  60.       Locked          =   -1  'True  
  61.       MultiLine       =   -1  'True  
  62.       ScrollBars      =   2  'Vertical  
  63.       TabIndex        =   1  
  64.       Top             =   90  
  65.       Width           =   5055  
  66.    End 
  67.    Begin MSWinsockLib.Winsock sckTest   
  68.       Left            =   1380  
  69.       Top             =   2160  
  70.       _ExtentX        =   741  
  71.       _ExtentY        =   741  
  72.       _Version        =   393216  
  73.    End 
  74. End 
  75. Attribute VB_Name = "frmTest" 
  76. Attribute VB_GlobalNameSpace = False 
  77. Attribute VB_Creatable = False 
  78. Attribute VB_PredeclaredId = True 
  79. Attribute VB_Exposed = False 
  80. Option Explicit  
  81.  
  82. '--------------------------------------------------  
  83. '  
  84. '   通讯测试  
  85. '  
  86. '   author: 木炭(WoodCoal)  
  87. '   homepage: http://www.woodcoal.cn/  
  88. '   memo: 简单网络通讯测试工具  
  89. '   release: 2009-03-18  
  90. '  
  91. '--------------------------------------------------  
  92.  
  93. Private Sub cmdClose_Click()  
  94.     sckTest.Close  
  95. End Sub 
  96.  
  97. Private Sub cmdSend_Click()  
  98.     If sckTest.State <> sckClosed Then 
  99.         sckTest.Close  
  100.     End If 
  101.     sckTest.Connect txtIP.Text, txtPort.Text  
  102. End Sub 
  103.  
  104. Private Sub Form_Load()  
  105.     txtCommand.Text = "GET / HTTP/1.1" & vbCrLf & _  
  106.                     "Accept: */*" & vbCrLf & _  
  107.                     "Accept-Encoding: gzip , deflate" & vbCrLf & _  
  108.                     "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; Maxthon)" & vbCrLf & _  
  109.                     "Host: 127.0.0.1" & vbCrLf & _  
  110.                     "Connection: Keep-Alive" & vbCrLf & vbCrLf  
  111. End Sub 
  112.  
  113. Private Sub sckTest_Close()  
  114.     sckTest.Close  
  115. End Sub 
  116.  
  117. Private Sub sckTest_Connect()  
  118.     txtInfo.Text = "" 
  119.     sckTest.SendData txtCommand.Text  
  120. End Sub 
  121.  
  122. Private Sub sckTest_DataArrival(ByVal bytesTotal As Long)  
  123.     Dim strData As String 
  124.     sckTest.GetData strData, vbString  
  125.     txtInfo.Text = txtInfo.Text & strData  
  126. End Sub 
  127.  
  128. Private Sub sckTest_Error(ByVal Number As Integer, Description As StringByVal Scode As LongByVal Source As StringByVal HelpFile As StringByVal HelpContext As Long, CancelDisplay As Boolean)  
  129.     MsgBox Description  
  130. End Sub 
  131.  
  132. Private Sub sckTest_SendComplete()  
  133.     'sckTest.Close  
  134. End Sub 

 

· 本文由 木炭 发布在《激情燃烧的木炭》 上,原文地址为:http://www.woodcoal.cn/product/tools/2009318-1680-573.html(转载请保留本信息、全文内容和链接)

· 点击下载《通讯测试》中涉及到的附件

发表评论

已经有 0 位朋友发表了对《通讯测试》的看法
 
登录名:  密码:   登录  注册
评论: 
User:
Contact:
验证码:  
  [Ctrl+Enter]

快捷导航

  • 上一篇:没有了
  • 下一篇:没有了

推荐文章