Call Sleep(1000) Next i 接收: Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long) Dim InGetMsg As client_request_t ReDim InBuf(Len(InGetMsg)) For i = 0 To Len(InGetMsg) - 1 Winsock1.GetData InBuf(i) Next i CopyMemory InGetMsg, InBuf(0), Len(InGetMsg) if ;;;;;then .....ElseIf OutGetClientReq.command = GetPMTofPROGRAM Then 'If InGetMsg.info(0) = &H2 Then '获取的info数据是PMT表格 Dim PMTMsg As PMT
Dim Program_Number As Long 'Dim PMT_PID_Lin As Long
ElseIf &HA < CInt(PMTMsg.ppmt_info.stream_type) And CInt(PMTMsg.ppmt_info.stream_type) < &H7F Then Set ASINode = FrmMulti.TreeView1.Nodes.Add("PMT" & Hex(PMTMsg.PID), tvwChild, "stream_type" & Str(u), "PID:&H" & Hex(PMTMsg.ppmt_info.elementary_PID) & " ITU-T Rec.H.222.0|ISO/IEC 13818-1保留")
Else Set ASINode = FrmMulti.TreeView1.Nodes.Add("PMT" & Hex(PMTMsg.PID), tvwChild, "stream_type" & Str(u), "PID:&H" & Hex(PMTMsg.ppmt_info.elementary_PID) & " 用户私用") End If s = s + ES_info_length+5 Loop While s <= 3 + PMTMsg.section_length - 1 - 4 - 5 'elseif... then ... else .. end if end sub我觉得来一次数据应该同样的数据处理一次,但是数据有时候来,有时候不来,并且来的次数并不和发送的次数一样
OutGetClientReq.old_prog_num = InPmt(i).Program_Number
OutGetClientReq.old_pid = InPmt(i).PID
'加入PMT的PID信息
CopyMemory OutBuf(0), OutGetClientReq, Len(OutGetClientReq)
Winsock1.SendData OutBuf
Call Sleep(1000)
Next i
接收:
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim InGetMsg As client_request_t
ReDim InBuf(Len(InGetMsg))
For i = 0 To Len(InGetMsg) - 1
Winsock1.GetData InBuf(i)
Next i
CopyMemory InGetMsg, InBuf(0), Len(InGetMsg)
if ;;;;;then
.....ElseIf OutGetClientReq.command = GetPMTofPROGRAM Then
'If InGetMsg.info(0) = &H2 Then '获取的info数据是PMT表格
Dim PMTMsg As PMT
Dim Program_Number As Long
'Dim PMT_PID_Lin As Long
Program_Number = CInt(InGetMsg.info(3)) * 256 + CInt(InGetMsg.info(4))
'循环判定这一次接受的是哪一个PID的信息
For i = 0 To NumPmt - 1
If InPmt(i).Program_Number = Program_Number Then
PMTMsg.PID = InPmt(i).PID
End If
Next i
'12位有效,但是最高两位为"00",故需要屏蔽6位
PMTMsg.section_length = CInt(InGetMsg.info(1) And &H3) * 256 + CInt(InGetMsg.info(2))
Dim Program_Info_Length As Long
'12位有效,但是最高两位为"00",故需要屏蔽6位
Program_Info_Length = CInt(InGetMsg.info(10) And &H3) * 256 + CInt(InGetMsg.info(11))
Dim ES_info_length As Long
Dim s As Long
s = 12 + Program_Info_Length - 1 '开始值
Do
ES_info_length = 0
'12位有效,但是最高两位为"00",故需要屏蔽6位
ES_info_length = CInt(InGetMsg.info(s + 3) And &H3) * 256 + CInt(InGetMsg.info(s + 4))
PMTMsg.ppmt_info.elementary_PID = Val(InGetMsg.info(s + 1) And &H1F) * 256 + Val(InGetMsg.info(s + 2))
PMTMsg.ppmt_info.stream_type = InGetMsg.info(s)
If PMTMsg.ppmt_info.stream_type = &H0 Then
set ASINode = FrmMulti.TreeView1.Nodes.Add("PMT" & Hex(PMTMsg.PID), tvwChild, "stream_type" & Str(u), "PID:&H" & Hex(PMTMsg.ppmt_info.elementary_PID) & " ITU-T|ISO/IEC保留")
ElseIf PMTMsg.ppmt_info.stream_type = &H1 Then
Set ASINode = FrmMulti.TreeView1.Nodes.Add("PMT" & Hex(PMTMsg.PID), tvwChild, "stream_type" & Str(u), "PID:&H" & Hex(PMTMsg.ppmt_info.elementary_PID) & " ISO/IEC保留 11172 视频")
ElseIf PMTMsg.ppmt_info.stream_type = &H2 Then
Set ASINode = FrmMulti.TreeView1.Nodes.Add("PMT" & Hex(PMTMsg.PID), tvwChild, "stream_type" & Str(u), "PID:&H" & Hex(PMTMsg.ppmt_info.elementary_PID) & " ITU-T Rec.H.262|ISO/IEC 13818-2 视频")
ElseIf PMTMsg.ppmt_info.stream_type = &H3 Then
Set ASINode = FrmMulti.TreeView1.Nodes.Add("PMT" & Hex(PMTMsg.PID), tvwChild, "stream_type" & Str(u), "PID:&H" & Hex(PMTMsg.ppmt_info.elementary_PID) & " ISO/IEC 11172音频")
ElseIf PMTMsg.ppmt_info.stream_type = &H4 Then
Set ASINode = FrmMulti.TreeView1.Nodes.Add("PMT" & Hex(PMTMsg.PID), tvwChild, "stream_type" & Str(u), "PID:&H" & Hex(PMTMsg.ppmt_info.elementary_PID) & " ISO/IEC 13818-3音频")
ElseIf PMTMsg.ppmt_info.stream_type = &H5 Then
Set ASINode = FrmMulti.TreeView1.Nodes.Add("PMT" & Hex(PMTMsg.PID), tvwChild, "stream_type" & Str(u), "PID:&H" & Hex(PMTMsg.ppmt_info.elementary_PID) & " ITU-T Rec.h.222.0|ISO/IEC 13818-1私用分段")
ElseIf PMTMsg.ppmt_info.stream_type = &H6 Then
Set ASINode = FrmMulti.TreeView1.Nodes.Add("PMT" & Hex(PMTMsg.PID), tvwChild, "stream_type" & Str(u), "PID:&H" & Hex(PMTMsg.ppmt_info.elementary_PID) & " 含有私用数据的ITU-T Rec.H.222.0|ISO/IEC 13818-1 PEC分组")
ElseIf PMTMsg.ppmt_info.stream_type = &H7 Then
Set ASINode = FrmMulti.TreeView1.Nodes.Add("PMT" & Hex(PMTMsg.PID), tvwChild, "stream_type" & Str(u), "PID:&H" & Hex(PMTMsg.ppmt_info.elementary_PID) & " ISO/IEC 13522MHEG")
ElseIf PMTMsg.ppmt_info.stream_type = &H8 Then
Set ASINode = FrmMulti.TreeView1.Nodes.Add("PMT" & Hex(PMTMsg.PID), tvwChild, "stream_type" & Str(u), "PID:&H" & Hex(PMTMsg.ppmt_info.elementary_PID) & " ITU-T Rec.H.222.0|ISO/IEC 13818-1 DSN CC")
ElseIf PMTMsg.ppmt_info.stream_type = &H9 Then
Set ASINode = FrmMulti.TreeView1.Nodes.Add("PMT" & Hex(PMTMsg.PID), tvwChild, "stream_type" & Str(u), "PID:&H" & Hex(PMTMsg.ppmt_info.elementary_PID) & " ITU-T Rec.H.222.0|ISO/IEC 13818-1/11172-1")
ElseIf &HA < CInt(PMTMsg.ppmt_info.stream_type) And CInt(PMTMsg.ppmt_info.stream_type) < &H7F Then
Set ASINode = FrmMulti.TreeView1.Nodes.Add("PMT" & Hex(PMTMsg.PID), tvwChild, "stream_type" & Str(u), "PID:&H" & Hex(PMTMsg.ppmt_info.elementary_PID) & " ITU-T Rec.H.222.0|ISO/IEC 13818-1保留")
Else
Set ASINode = FrmMulti.TreeView1.Nodes.Add("PMT" & Hex(PMTMsg.PID), tvwChild, "stream_type" & Str(u), "PID:&H" & Hex(PMTMsg.ppmt_info.elementary_PID) & " 用户私用")
End If
s = s + ES_info_length+5
Loop While s <= 3 + PMTMsg.section_length - 1 - 4 - 5 'elseif... then
...
else
..
end if
end sub我觉得来一次数据应该同样的数据处理一次,但是数据有时候来,有时候不来,并且来的次数并不和发送的次数一样
就是说和对方发送不会在次数上一致通常dataarrival比发送次数少所以每次dataarrival必须处理所有的数据,而不是一次的数据,有可能一个
dataarrival可以取出一个或者多于一个也可能少于一个的数据[我这里的个数只你发送的结构]每次接收数据并处理完以后,可以尝试再取一次数据,如果没有再退出过程
那么最后可能dataarrival将不再触发,对方也会发送失败。因为接收端的缓冲区已经被充满
改成 doevents
Call Sleep(1000)
是 调用api让系统休眠把 他会把全部的操作挂起。在winsock中不要用
你在测试一下有问题在留言
去掉 这句 Call Sleep(1000)
改成 doevents
然后在测试如果还有问题在回帖