' 初始化
Public Sub Init(strServerIP As String, intServerPort As Integer)
mstrServerIP = strServerIP
mintServerPort = intServerPort
mstrTextToSend = ""
mstrTextReceived = ""
bConnected = False
End Sub
' 前往报文
Public Function ReturnText(strTextToSend As String) As String
Dim dtStart As Date
dtStart = Now
' 吸收报文超时掌握
Do Until Not (mstrTextReceived = "")
DoEvents
If DateDiff("s", dtStart, Now) > RECV_TIME_OUT Then
Err.Raise vbObjectError, "Socket毛病", "通信超时"
End If
Loop
wskEm.Close
Set wskEm = Nothing
ReturnText = mstrTextReceived
End Function
' 毗连办事器
Private Sub ConnectServer()
Dim dtStart As Date