vb监听程序

来源:百度知道 编辑:UC知道 时间:2024/05/30 19:23:28
这里是个监听程序 请问为什么log会没有显示,昨晚调试的时候还可以。
我是自学的,很多地方不懂,请懂的朋友赐教。
Dim tmpstr As String
Dim NOW_OUT As Integer '总共出去连接的有几个Winsock
Private Sub addport_Click()
Listports.AddItem txtADDPORT.Text
End Sub
Private Sub exitme_Click()
Unload Me
End Sub
Private Sub Form_Load()
txtlog.Text = "Log:" & vbCrLf
NOW_OUT = 1
End Sub

Private Sub Label4_Click()
Unload Me
End Sub

Private Sub Label5_Click()
MsgBox (" This is DEMO make by F-king :) URL://gui.whitecell.org Mail:root@hacker.com.cn")
End Sub

Private Sub Label6_Click()
Me.Hide
End Sub

Private Sub listen_Click()
On Error Resume Next
If listen.Caption = "Working..." Then
For i = 0 To Listports.ListCount - 1
Load Winsock1(i + 1) '加载监听端口的winsock1数组控件
Winsock1(i + 1).LocalPort = Listports.List(i) '设定端口
Winsock1(i + 1).listen '监听
Next i

简单的例子
S端
Dim MaxIndex As Integer

Private Sub Form_Load()
wskServer(0).Listen
End Sub

Private Sub wskServer_ConnectionRequest(Index As Integer, ByVal requestID As Long)
MaxIndex = MaxIndex + 1
Load wskServer(MaxIndex)
wskServer(MaxIndex).Accept requestID
wskServer(MaxIndex).SendData SetData(0, "hello")
End Sub

Public Function SetData(ByVal TypeId As Integer, ByVal Value As String)
SetData = "<T>" & TypeId & "</T><D>" & Value & "</D>"
End Function

Public Function GetData(ByVal s As String)
Dim re As Object
Set re = CreateObject("VBScript.RegExp")
re.IgnoreCase = True
re.Global = True
re.Pattern = "<T>(.*?)</T><D>(.*?)</D>"
Dim col As New Collection
For Each obj In re.Execute(s)
col.Add Array