?? frm_rcvmo.frm
字號:
VERSION 5.00
Object = "{248DD890-BB45-11CF-9ABC-0080C7E7B78D}#1.0#0"; "MSWINSCK.OCX"
Begin VB.Form Frm_rcvMO
Caption = "接收短消息 MO"
ClientHeight = 1950
ClientLeft = 60
ClientTop = 345
ClientWidth = 4305
LinkTopic = "Form2"
ScaleHeight = 1950
ScaleWidth = 4305
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Cmd_start
Caption = "開始"
Height = 435
Left = 1080
TabIndex = 0
Top = 360
Width = 1170
End
Begin MSWinsockLib.Winsock WsockMO
Index = 0
Left = 420
Top = 315
_ExtentX = 741
_ExtentY = 741
_Version = 393216
End
Begin VB.Label Lbl_show
Caption = "Lbl_show"
BeginProperty Font
Name = "宋體"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 435
Left = 240
TabIndex = 1
Top = 1080
Width = 3585
End
End
Attribute VB_Name = "Frm_rcvMO"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
'Dim Msg_bin() As Byte '接收短消息的原始數據
Private Sub Form_Load()
'開始監聽
WsockMO(0).LocalPort = 8801
WsockMO(0).Listen
Lbl_show = "服務器已準備好。"
Open App.Path & "\log\log" & Date & ".txt" For Append As #1 'save to a log file
Print #1, Time & " MO 開始運行"
Close #1
End Sub
Private Sub Form_Unload(Cancel As Integer)
Open App.Path & "\log\log" & Date & ".txt" For Append As #1 'save to a log file
Print #1, Time & " MO 停止運行"
Close #1
End Sub
'=================================================================================================================
'服務器端 MO
Private Sub Wsockmo_ConnectionRequest(Index As Integer, ByVal requestID As Long)
'應答申請
Static Nsocket As Integer
'查找一個有效的下標
Nsocket = Nsocket + 1
Load WsockMO(Nsocket)
WsockMO(Nsocket).Accept requestID
Lbl_show = "有客戶請求。建立連接" & Index & requestID
Open App.Path & "\log\log" & Date & ".txt" For Append As #1 'save to a log file
Print #1, Time & " MO 有SMG請求。建立TCP連接" & Index & " " & requestID
Close #1
End Sub
Private Sub WsockMO_Close(Index As Integer)
'斷開和SMG的連接
WsockMO(Index).Close
Unload WsockMO(Index)
Open App.Path & "\log\log" & Date & ".txt" For Append As #1 'save to a log file
Print #1, Time & " MO 有一個SMG斷開TCP連接,序號" & Index
Close #1
End Sub
Private Sub Wsockmo_DataArrival(Index As Integer, ByVal bytesTotal As Long)
'有數據傳輸
Dim s1 As Long
Dim XuLieHao() As Byte
Dim Msg_bin() As Byte
WsockMO(Index).GetData Msg_bin, vbByte, 4 '包長度
WsockMO(Index).GetData Msg_bin, vbByte, 4 'ID
s1 = GetID(Msg_bin)
WsockMO(Index).GetData XuLieHao, vbByte, 12 '節點'時間'序號
Open App.Path & "\log\log" & Date & ".txt" For Append As #1 'save to a log file
Print #1, Time & " MO 收到一個SMG消息,winsock序號:" & Index & "。消息頭:" & s1
Close #1
Select Case s1
Case SGIP_BIND
'SMG申請連接
WsockMO(Index).GetData Msg_bin, vbByte '節點'時間'序號
SendResp 0, WsockMO(Index), SGIP_BIND_RESP, XuLieHao
Case SGIP_DELIVER
'SMG發送的短信
SendResp DeliverMX(WsockMO(Index)), WsockMO(Index), SGIP_DELIVER_RESP, XuLieHao
Case SGIP_REPORT
'SMG用該命令通知SP一條Submit命令所發送的MT當前結果
SendResp ReportMX(WsockMO(Index)), WsockMO(Index), SGIP_REPORT_RESP, XuLieHao
Case SGIP_UNBIND
'SMG申請斷開連接
WsockMO(Index).GetData Msg_bin
SendResp 0, WsockMO(Index), SGIP_UNBIND_RESP, XuLieHao
Case Else
WsockMO(Index).GetData Msg_bin, vbByte '節點'時間'序號
'MsgBox RES
End Select
WsockMO(Index).GetData Msg_bin, vbByte
Lbl_show = "有數據傳送" & Index
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -