高俩位二进制数据 | 意义 |
00 | 这个数据包的 |
01 | 这个数据包的 |
10 | |
11 |
十六进制值 | 标识名称 | 标识含义 |
0x01 | name | 标记对象的名称(通常是文件的文件名) |
0xc3 | length | 以字节为单位计算的对象长度 |
0x44 | time | 时间(以iso 8601规范为标准) |
0x480x49 | bodyend of body | 标识一个对象数据块的开始标识这是对象的最后一个数据块 |
0x80 | connect | 标识申请开始一个对象传输会话,并可以在这个数据包中告知红外接收方一些必要的兼容性信息。 |
0x81 | disconnect | 标识对象传输会话结束 |
0x020x82 | putfinal_put | 发送对象的put动作(当标识为0x82时说明这是最后的一个put动作) |
0xa0 | success | 说明接收端已成功收到put动作发送的所有数据(一般是在成功收到final_put标识的数据包后的反馈) |
0x90 | continue | 说明接收端已收到put动作发送的数据,因为final_put还没出现,所以要求发送端继续发送数据。 |
字节0 | 字节1,2 | 字节三以后的数据 |
操作码 | 整个通信数据包的长度 | 通讯的数据 |
字节0 | 字节1、2 | 字节3 | 字节4 | 字节5、6 | 字节7 |
connect操作码(0x80) | connect数据包的总长度 | obex协议的版本(目前为1.0,16进制表示为0x10) | 保留未用,设为0 | 最大可处理的obex包长度 | 其它的数据包(可选) |
字节0 | 字节1、2 | 字节3 | 字节4 | 字节5、6 | 字节7 |
响应的操作码 | 响应数据包的总长度 | obex协议的版本(目前为1.0,16进制表示为0x10) | 保留未用,设为0 | 最大可处理的obex包长度 | 其它的数据包(可选) |
字节0 | 字节1,2 | 字节三以后的数据 |
put操作码(0x02)final_put操作码(0x82) | 整个通信数据包的长度 | 通讯的数据(由其它的例如name/body等数据包构成) |
字节0 | 字节1,2 | 字节三以后的数据 |
响应操作码典型的有两个值:success操作码(0xa0)continue操作码(0x90 ) | 整个通信数据包的长度 | 通讯的数据(由其它的例如name/body等数据包构成) |
字节0 | 字节1,2 | 字节三以后的数据 |
disconnect操作码 | 整个通信数据包的长度 | 可选的通讯的数据(由其它的数据包构成) |
字节0 | 字节1,2 | 字节三以后的数据 |
success操作码(0xa0)服务不可用操作码(0xd3) | 整个通信数据包的长度 | 可选的通讯的数据(由其它的数据包构成) |
irdaclient | 提供连接信息,并创建客户端连接对象,用以打开和关闭与服务器的连接。 |
irdadeviceinfo | 提供客户端在发现查询过程中获取的有关可用服务器和端口的信息。 |
irdalistener | 将套接字置于侦听状态,以监视来自指定服务或网络地址的连接。 |
dim taobjirdadeviceinfo() as sockets.irdadeviceinfo dim tobjirdaclient as new sockets.irdaclient '开始检索附近的红外设备并加入到列表中,最多只搜索7个设备 taobjirdadeviceinfo = tobjirdaclient.discoverdevices(7) |
dim tobjirdaclient as new sockets.irdaclient 'ni_objirdadeviceinfo是上文介绍的irdadeviceinfo对象,以下语句的含义就是连接到'deviceid指定的红外设备上,这个设备提供obex服务。 dim tobjirdaendpoint as new irdaendpoint(ni_objirdadeviceinfo.deviceid, "obex") try tobjirdaclient.connect(tobjirdaendpoint) catch ex as exception messagebox.show("irda socket connect 状态失败") end try |
imports system.net imports system.net.sockets public class clsirdaobexoperator 'obex常数 public const cobex_version as byte = &h10 public const cobex_connectflags as byte = &h0 public const cobex_connect as byte = &h80 public const cobex_disconnect as byte = &h81 public const cobex_put as byte = &h2 public const cobex_name as byte = &h1 public const cobex_put_final as byte = &h82 public const cobex_length as byte = &hc3 public const cobex_body as byte = &h48 public const cobex_end_of_body as byte = &h49 public const cobex_continue as byte = &h90 public const cobex_success as byte = &ha0 '向外界公布可直接修改的变量 public m_i32obexmaxsendbufferlen as int32 = 255 public m_i32obexmaxreceivebufferlen as int32 = 1024 public m_i32obexmaxpacketsize as int16 = &h808 '将一个16位整数转为2个字节的数组,并存入参数中指定索引开始的字节数组处(低位字在低字节,高位字在高字节) private function fnint16tobytearray(byval ni_i16convert as int16, byref ni_abytdest() as byte, byval ni_i32startindex as int32) as boolean ni_abytdest(ni_i32startindex) = ni_i16convert and &hff ni_abytdest(ni_i32startindex + 1) = ni_i16convert >> 8 end function '将一个16位整数转为2个字节的数组,并存入参数中指定索引开始的字节数组处 private function fnint16tobytearraylowbytetohightposition(byval ni_i16convert as int16, byref ni_abytdest() as byte, byval ni_i32startindex as int32) as boolean ni_abytdest(ni_i32startindex + 1) = ni_i16convert and &hff ni_abytdest(ni_i32startindex) = ni_i16convert >> 8 end function '将一个32位整数转为4个字节的数组,并存入参数中指定索引开始的字节数组处 private function fnint32tobytearraylowbytetohightposition(byval ni_i32convert as int16, byref ni_abytdest() as byte, byval ni_i32startindex as int32) as boolean dim ti32tempa as int32 = ni_i32convert ni_abytdest(ni_i32startindex + 3) = ni_i32convert and &hff ni_abytdest(ni_i32startindex + 2) = (ni_i32convert and &hff00) >> 8 ni_abytdest(ni_i32startindex + 1) = (ni_i32convert and &hff0000) >> 16 ni_abytdest(ni_i32startindex) = (ti32tempa and &hff000000) >> 24 end function '将本设备中指定的文件传到指定的设备中去 public function fnsendfiletoirdadevice(byval ni_objirdadeviceinfo as irdadeviceinfo, _ byval ni_strfilepath as string) as boolean 'ni_objirdadeviceinfo:指定红外设备的irdainfo结构 'ni_strfilepath:要传输的文件路径 '返回值:成功返回true dim tobjirdaclient as new sockets.irdaclient dim tobjirdaendpoint as new irdaendpoint(ni_objirdadeviceinfo.deviceid, "obex") dim tabytsendbuffer(m_i32obexmaxsendbufferlen * 2) as byte dim tabytreceivebuffer(m_i32obexmaxreceivebufferlen) as byte dim tblntemp as boolean dim ti32tempa as int32, ti32tempb as int32, tietempc as int32 dim tbyttempa as byte dim ti32loopa as int32 dim tobjbinaryreader as io.binaryreader dim tobjfilestream as io.filestream dim tabyttempa() as byte, tabyttempb() as byte, tabyttempc() as byte, tabyttempd() as byte dim tabyttempe() as byte dim tobjobex_headers as new clsobexheaders dim ti32sendpackagespare as int32 '保存最大发送包数组-当前数据后的剩余空间 dim tobjfileinfo as io.fileinfo tobjfileinfo = new io.fileinfo(ni_strfilepath) try try tobjirdaclient.connect(tobjirdaendpoint) catch ex as exception messagebox.show("irda socket connect 状态失败") return false end try '创建一个最简单的连接信息 tabyttempa = tobjobex_headers.fncreateconnectheaderrequest(, , , m_i32obexmaxpacketsize) try tobjirdaclient.getstream.write(tabyttempa, 0, tabyttempa.length) tobjirdaclient.getstream.flush() catch ex as exception messagebox.show("obex_connect信息发送失败") application.doevents() return false end try if tobjirdaclient.getstream.canread = true then try tobjirdaclient.getstream.read(tabytreceivebuffer, 0, 7) catch ex as exception messagebox.show("接收obex_connect响应消息失败") return false end try if tabytreceivebuffer(0) <> cobex_success then messagebox.show("obex_connect没接收到相应的响应") return false end if end if '发送put包 'name包 tabyttempa = tobjobex_headers.fncreatenameheader(io.path.getfilename(ni_strfilepath)) ti32tempa = tabyttempa.length 'lenght包 tabyttempb = tobjobex_headers.fncreatelengthheader(tobjfileinfo.length) ti32tempb = tabyttempb.length '时间 tabyttempc = tobjobex_headers.fncreatetimeheaderiso(now) redim preserve tabyttempa(tabyttempa.length + tabyttempb.length + tabyttempc.length) tabyttempb.copyto(tabyttempa, ti32tempa) tabyttempc.copyto(tabyttempa, ti32tempa + ti32tempb) tabyttempa = tobjobex_headers.fncreateputheader(tabyttempa) '将名称、时间、文件长度等基本信息先发出去 try tobjirdaclient.getstream.write(tabyttempa, 0, tabyttempa.length) catch ex as exception return false end try try tobjirdaclient.getstream.read(tabytreceivebuffer, 0, tabytreceivebuffer.length) catch ex as exception '接收服务器端响应时失败 tobjirdaclient.getstream.close() tobjirdaclient.close() return false end try if tabytreceivebuffer(0) <> cobex_success and tabytreceivebuffer(0) <> cobex_continue then '没有收到服务器的对应的响应信息 tobjirdaclient.getstream.close() tobjirdaclient.close() return false end if '开始正式发送文件的数据 try tobjfilestream = io.file.open(ni_strfilepath, io.filemode.open, io.fileaccess.read) tobjbinaryreader = new io.binaryreader(tobjfilestream) catch ex as exception messagebox.show("打开文件时出现错误") tobjirdaclient.getstream.close() tobjirdaclient.close() return false end try '读出文件的数据放到body中,总长度必须少于最大发送长度-put标志的3字节-body标志的3字节 '最多可发送的文件信息长度 ti32sendpackagespare = m_i32obexmaxsendbufferlen - 6 '循环读取文件的内容,并发送到服务方 for ti32loopa = 1 to math.ceiling(tobjfileinfo.length / ti32sendpackagespare) try tabyttempa = tobjbinaryreader.readbytes(ti32sendpackagespare) catch ex as exception tobjirdaclient.getstream.close() tobjirdaclient.close() return false end try '构建合适的put包并发送 tabyttempb = tobjobex_headers.fncreatebodyheader(tabyttempa) 'body标志 tabyttempa = tobjobex_headers.fncreateputheader(tabyttempb) '开始发送 try tobjirdaclient.getstream.write(tabyttempa, 0, tabyttempa.length) tobjirdaclient.getstream.flush() catch ex as exception tobjirdaclient.getstream.close() tobjirdaclient.close() return false end try try tobjirdaclient.getstream.read(tabytreceivebuffer, 0, tabytreceivebuffer.length) catch ex as exception '接收服务器端响应时失败 tobjirdaclient.getstream.close() tobjirdaclient.close() return false end try if tabytreceivebuffer(0) <> cobex_success and tabytreceivebuffer(0) <> cobex_continue then '没有收到服务器的对应的响应信息 tobjirdaclient.getstream.close() tobjirdaclient.close() return false end if next '关闭文件 tobjbinaryreader.close() tobjfilestream.close() if ti32tempa then end if '文件数据已全部发送完毕,发送结束的final_put 包 'endbody包 tabyttempa = tobjobex_headers.fncreateendofbodyheader(nothing) 'putfinal tabyttempa = tobjobex_headers.fncreateput_finalheaderresponse(tabyttempa) try tobjirdaclient.getstream.write(tabyttempa, 0, tabyttempa.length) tobjirdaclient.getstream.flush() catch ex as exception tobjirdaclient.getstream.close() tobjirdaclient.close() return false end try try tobjirdaclient.getstream.read(tabytreceivebuffer, 0, tabytreceivebuffer.length) catch ex as exception tobjirdaclient.getstream.close() tobjirdaclient.close() return false end try if tabytreceivebuffer(0) <> cobex_success then '没有收到服务器的对应的响应信息 tobjirdaclient.getstream.close() tobjirdaclient.close() return false end if '发送disconnect包 tabyttempa = tobjobex_headers.fncreatedisconnectheaderrequest() try tobjirdaclient.getstream.write(tabyttempa, 0, tabyttempa.length) tobjirdaclient.getstream.flush() catch ex as exception tobjirdaclient.getstream.close() tobjirdaclient.close() return false end try tobjirdaclient.close() catch ex as exception messagebox.show("过程发生不明错误") return false end try '代码能来到这儿就是正常完成任务了 msgbox("红外操作成功") return true end function end class clsobexheaders.vb文件的代码: public class clsobexheaders #region "obex常数" public const cobex_version as byte = &h10 public const cobex_connectflags as byte = &h0 public const cobex_connect as byte = &h80 public const cobex_disconnect as byte = &h81 public const cobex_put as byte = &h2 public const cobex_name as byte = &h1 public const cobex_put_final as byte = &h82 public const cobex_length as byte = &hc3 public const cobex_body as byte = &h48 public const cobex_end_of_body as byte = &h49 public const cobex_time_iso as byte = &h44 public const cobex_continue as byte = &h90 public const cobex_success as byte = &ha0 #end region #region "类内私有函数" '将一个16位整数转为2个字节的数组,并存入参数中指定索引开始的字节数组处 private sub sbint16tobytearraylowbytetohightposition(byval ni_i16convert as int16, byref ni_abytdest() as byte, byval ni_i32startindex as int32) ni_abytdest(ni_i32startindex + 1) = ni_i16convert and &hff ni_abytdest(ni_i32startindex) = ni_i16convert >> 8 end sub ''将一个16位整数转为2个字节的数组,高位字放入高字节,并存入参数中指定索引开始的字节数组处 'private sub sbint16tobytearrayhightbytetohightposition(byval ni_i16convert as int16, byref ni_abytdest() as byte, byval ni_i32startindex as int32) ' ni_abytdest(ni_i32startindex) = ni_i16convert and &hff ' ni_abytdest(ni_i32startindex + 1) = ni_i16convert >> 8 'end sub '将一个32位整数转为4个字节的数组,并存入参数中指定索引开始的字节数组处 private sub sbint32tobytearraylowbytetohightposition(byval ni_i32convert as int16, byref ni_abytdest() as byte, byval ni_i32startindex as int32) dim ti32tempa as int32 = ni_i32convert ni_abytdest(ni_i32startindex + 3) = ni_i32convert and &hff ni_abytdest(ni_i32startindex + 2) = (ni_i32convert and &hff00) >> 8 ni_abytdest(ni_i32startindex + 1) = (ni_i32convert and &hff0000) >> 16 ni_abytdest(ni_i32startindex) = (ti32tempa and &hff000000) >> 24 end sub #end region '创建一个新的connectheader客户端请求信息 public function fncreateconnectheaderrequest(optional byval ni_abytotherheaders as byte() = nothing, _ optional byval ni_bytobex_version as byte = cobex_version, _ optional byval ni_bytflags as byte = cobex_connectflags, _ optional byval ni_i16maxpacketlength as int16 = 255) as byte() dim tabytfuncreturn() as byte if not (ni_abytotherheaders is nothing) then redim tabytfuncreturn(7 + ni_abytotherheaders.length - 1) else redim tabytfuncreturn(6) end if tabytfuncreturn(0) = cobex_connect tabytfuncreturn(3) = ni_bytobex_version tabytfuncreturn(4) = ni_bytflags sbint16tobytearraylowbytetohightposition(ni_i16maxpacketlength, tabytfuncreturn, 5) if ni_abytotherheaders is nothing then '没有其它的头信息了 '加入connect包的长度 call sbint16tobytearraylowbytetohightposition(7, tabytfuncreturn, 1) else '还有其它头信息 ni_abytotherheaders.copyto(tabytfuncreturn, 7) call sbint16tobytearraylowbytetohightposition(ni_abytotherheaders.length + 7, tabytfuncreturn, 1) end if return tabytfuncreturn end function '创建一个新的connectheader的服务器端响应信息数据 public function fncreateconnectheaderresponse(optional byval ni_abytotherheaders as byte() = nothing, _ optional byval ni_bytobex_version as byte = cobex_version, _ optional byval ni_bytflags as byte = cobex_connectflags, _ optional byval ni_i16maxpacketlength as int16 = 255) as byte() dim tabytfuncreturn() as byte if not (ni_abytotherheaders is nothing) then redim tabytfuncreturn(7 + ni_abytotherheaders.length - 1) else redim tabytfuncreturn(6) end if tabytfuncreturn(0) = cobex_success tabytfuncreturn(3) = ni_bytobex_version tabytfuncreturn(4) = ni_bytflags sbint16tobytearraylowbytetohightposition(ni_i16maxpacketlength, tabytfuncreturn, 5) if ni_abytotherheaders is nothing then '没有其它的头信息了 '加入connect包的长度 call sbint16tobytearraylowbytetohightposition(7, tabytfuncreturn, 1) else '还有其它头信息 ni_abytotherheaders.copyto(tabytfuncreturn, 7) call sbint16tobytearraylowbytetohightposition(ni_abytotherheaders.length + 7, tabytfuncreturn, 1) end if return tabytfuncreturn end function '创建一个新的disconnectheader客户请求信息 public function fncreatedisconnectheaderrequest(optional byval ni_abytotherheaders as byte() = nothing) as byte() dim tabytfuncreturn() as byte if not (ni_abytotherheaders is nothing) then '有其它的数据包要附在后面 redim tabytfuncreturn(3 + ni_abytotherheaders.length - 1) else redim tabytfuncreturn(2) end if tabytfuncreturn(0) = cobex_disconnect if ni_abytotherheaders is nothing then '没有其它的头信息了 '加入包的长度 call sbint16tobytearraylowbytetohightposition(3, tabytfuncreturn, 1) else '还有其它头信息 ni_abytotherheaders.copyto(tabytfuncreturn, 3) call sbint16tobytearraylowbytetohightposition(ni_abytotherheaders.length + 3, tabytfuncreturn, 1) end if return tabytfuncreturn end function '创建一个新的continueheader信息 public function fncreatecontinueheaderresponse(optional byval ni_abytotherheaders as byte() = nothing) as byte() dim tabytfuncreturn() as byte if not (ni_abytotherheaders is nothing) then '有其它的数据包要附在后面 redim tabytfuncreturn(3 + ni_abytotherheaders.length - 1) else redim tabytfuncreturn(2) end if tabytfuncreturn(0) = cobex_continue if ni_abytotherheaders is nothing then '没有其它的头信息了 '加入包的长度 call sbint16tobytearraylowbytetohightposition(3, tabytfuncreturn, 1) else '还有其它头信息 ni_abytotherheaders.copyto(tabytfuncreturn, 3) call sbint16tobytearraylowbytetohightposition(ni_abytotherheaders.length + 3, tabytfuncreturn, 1) end if return tabytfuncreturn end function '创建一个新的successheader信息 public function fncreatesuccessheaderresponse(optional byval ni_abytotherheaders as byte() = nothing) as byte() dim tabytfuncreturn() as byte if not (ni_abytotherheaders is nothing) then '有其它的数据包要附在后面 redim tabytfuncreturn(3 + ni_abytotherheaders.length - 1) else redim tabytfuncreturn(2) end if tabytfuncreturn(0) = cobex_success if ni_abytotherheaders is nothing then '没有其它的头信息了 '加入包的长度 call sbint16tobytearraylowbytetohightposition(3, tabytfuncreturn, 1) else '还有其它头信息 ni_abytotherheaders.copyto(tabytfuncreturn, 3) call sbint16tobytearraylowbytetohightposition(ni_abytotherheaders.length + 3, tabytfuncreturn, 1) end if return tabytfuncreturn end function '创建一个新的timeheader信息 public function fncreatetimeheaderiso(byval ni_dtmdate as date, optional byval ni_abytotherheaders as byte() = nothing) as byte() dim tabytfuncreturn() as byte dim tstrdate as string dim tabyttempa() as byte 'tstrdate = ni_dtmdate.year & "." & ni_dtmdate.month & "." & ni_dtmdate.day & "t" & _ ' ni_dtmdate.hour & ":" & ni_dtmdate.minute & ":" & ni_dtmdate.second & "z" & controlchars.nullchar tstrdate = string.format("{0:yyyy/mm/dd/thh:mm:ss/z}", ni_dtmdate) & controlchars.nullchar tabyttempa = text.encoding.bigendianunicode.getbytes(tstrdate) if not (ni_abytotherheaders is nothing) then '有其它的数据包要附在后面 redim tabytfuncreturn(3 + tabyttempa.length + ni_abytotherheaders.length - 1) else redim tabytfuncreturn(2 + tabyttempa.length) end if tabytfuncreturn(0) = cobex_time_iso tabyttempa.copyto(tabytfuncreturn, 3) '将时间字节串放入返回数组中 if ni_abytotherheaders is nothing then '没有其它的头信息了 '加入包的长度 call sbint16tobytearraylowbytetohightposition(3 + tabyttempa.length, tabytfuncreturn, 1) else '还有其它头信息 ni_abytotherheaders.copyto(tabytfuncreturn, 3) call sbint16tobytearraylowbytetohightposition(ni_abytotherheaders.length + 3 + tabyttempa.length, tabytfuncreturn, 1) end if return tabytfuncreturn end function '创建一个新的bodyheader信息 public function fncreatebodyheader(byval ni_abytbodycontent() as byte, optional byval ni_abytotherheaders as byte() = nothing) as byte() dim tabytfuncreturn() as byte dim tabyttempa as byte dim ti32bodycontentlength as int32 = 0 '定义合适大小的数组以容纳bodyheader的内容 if not (ni_abytbodycontent is nothing) then '有body的内容 if not (ni_abytotherheaders is nothing) then '有其它的数据包要附在后面 redim tabytfuncreturn(3 + ni_abytbodycontent.length + ni_abytotherheaders.length - 1) ni_abytbodycontent.copyto(tabytfuncreturn, 3) ni_abytotherheaders.copyto(tabytfuncreturn, ni_abytbodycontent.length + 3) else redim tabytfuncreturn(2 + ni_abytbodycontent.length) ni_abytbodycontent.copyto(tabytfuncreturn, 3) end if else '没有body的内容 if not (ni_abytotherheaders is nothing) then '有其它的数据包要附在后面 redim tabytfuncreturn(3 + ni_abytotherheaders.length - 1) ni_abytotherheaders.copyto(tabytfuncreturn, 3) else redim tabytfuncreturn(2) end if end if tabytfuncreturn(0) = cobex_body '加入包的长度 call sbint16tobytearraylowbytetohightposition(tabytfuncreturn.length, tabytfuncreturn, 1) return tabytfuncreturn end function '创建一个新的endofbodyheader信息 public function fncreateendofbodyheader(byval ni_abytbodycontent() as byte, optional byval ni_abytotherheaders as byte() = nothing) as byte() dim tabytfuncreturn() as byte dim tabyttempa as byte dim ti32bodycontentlength as int32 = 0 if not (ni_abytbodycontent is nothing) then if not (ni_abytotherheaders is nothing) then '有其它的数据包要附在后面 redim tabytfuncreturn(3 + ni_abytbodycontent.length + ni_abytotherheaders.length - 1) ni_abytbodycontent.copyto(tabytfuncreturn, 3) ni_abytotherheaders.copyto(tabytfuncreturn, 3 + ni_abytbodycontent.length) else redim tabytfuncreturn(2 + ni_abytbodycontent.length) ni_abytbodycontent.copyto(tabytfuncreturn, 3) end if else '没有body内容 if not (ni_abytotherheaders is nothing) then '有其它的数据包要附在后面 redim tabytfuncreturn(3 + ni_abytotherheaders.length - 1) ni_abytotherheaders.copyto(tabytfuncreturn, 3) else redim tabytfuncreturn(2) end if end if '加入包的长度 call sbint16tobytearraylowbytetohightposition(tabytfuncreturn.length, tabytfuncreturn, 1) tabytfuncreturn(0) = cobex_end_of_body return tabytfuncreturn end function '创建一个新的lengthheader信息 public function fncreatelengthheader(byval ni_i32length as int32) as byte() dim tabytfuncreturn() as byte redim tabytfuncreturn(4) tabytfuncreturn(0) = cobex_length '加入包的内容 call sbint32tobytearraylowbytetohightposition(ni_i32length, tabytfuncreturn, 1) return tabytfuncreturn end function '创建一个新的nameheader信息 public function fncreatenameheader(byval ni_strname as string, optional byval ni_abytotherheaders as byte() = nothing) as byte() dim tabytfuncreturn() as byte dim tabyttempa() as byte dim ti32bodycontentlength as int32 = 0 tabyttempa = text.encoding.bigendianunicode.getbytes(ni_strname & controlchars.nullchar) if ni_strname <> "" then if not (ni_abytotherheaders is nothing) then '有其它的数据包要附在后面 redim tabytfuncreturn(3 + tabyttempa.length + ni_abytotherheaders.length - 1) else '没有其它数据包附后 redim tabytfuncreturn(2 + tabyttempa.length) end if else if not (ni_abytotherheaders is nothing) then '有其它的数据包要附在后面 redim tabytfuncreturn(3 + ni_abytotherheaders.length - 1) else redim tabytfuncreturn(2) end if end if tabytfuncreturn(0) = cobex_name if ni_strname <> "" then if ni_abytotherheaders is nothing then '没有其它的头信息了 '加入包的长度 call sbint16tobytearraylowbytetohightposition(3 + tabyttempa.length, tabytfuncreturn, 1) else '还有其它头信息 ni_abytotherheaders.copyto(tabytfuncreturn, 3) call sbint16tobytearraylowbytetohightposition(ni_abytotherheaders.length + tabyttempa.length + 3, tabytfuncreturn, 1) end if tabyttempa.copyto(tabytfuncreturn, 3) else '没有实际的body数据 if ni_abytotherheaders is nothing then '没有其它的头信息了 '加入包的长度 call sbint16tobytearraylowbytetohightposition(3, tabytfuncreturn, 1) else '还有其它头信息 ni_abytotherheaders.copyto(tabytfuncreturn, 3) call sbint16tobytearraylowbytetohightposition(ni_abytotherheaders.length + 3, tabytfuncreturn, 1) end if end if return tabytfuncreturn end function '创建一个新的putheader信息 public function fncreateputheader(optional byval ni_abytotherheaders as byte() = nothing) as byte() dim tabytfuncreturn() as byte if not (ni_abytotherheaders is nothing) then '有其它的数据包要附在后面 redim tabytfuncreturn(3 + ni_abytotherheaders.length - 1) else redim tabytfuncreturn(2) end if tabytfuncreturn(0) = cobex_put if ni_abytotherheaders is nothing then '没有其它的头信息了 '加入包的长度 call sbint16tobytearraylowbytetohightposition(3, tabytfuncreturn, 1) else '还有其它头信息 ni_abytotherheaders.copyto(tabytfuncreturn, 3) call sbint16tobytearraylowbytetohightposition(ni_abytotherheaders.length + 3, tabytfuncreturn, 1) end if return tabytfuncreturn end function '创建一个新的putheader信息 public function fncreateput_finalheaderresponse(optional byval ni_abytotherheaders as byte() = nothing) as byte() dim tabytfuncreturn() as byte if not (ni_abytotherheaders is nothing) then '有其它的数据包要附在后面 redim tabytfuncreturn(3 + ni_abytotherheaders.length - 1) else redim tabytfuncreturn(2) end if tabytfuncreturn(0) = cobex_put_final if ni_abytotherheaders is nothing then '没有其它的头信息了 '加入包的长度 call sbint16tobytearraylowbytetohightposition(3, tabytfuncreturn, 1) else '还有其它头信息 ni_abytotherheaders.copyto(tabytfuncreturn, 3) call sbint16tobytearraylowbytetohightposition(ni_abytotherheaders.length + 3, tabytfuncreturn, 1) end if return tabytfuncreturn end function end class |
新闻热点
疑难解答
图片精选