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

📄 frm_rcvmo.frm

📁 中国联通SGIP 2.0协议的源代码 java
💻 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 + -