怎样发送01h数据???急!!(200分)

  • 主题发起人 主题发起人 xingkong97
  • 开始时间 开始时间
X

xingkong97

Unregistered / Unconfirmed
GUEST, unregistred user!
我现在需要发送这样的字节:
01h 01h 0000h
请问我该怎样发送呀?
这个发送程序对不对?
u:=1;//U为byte型,占一个字节
clientsocket2.Socket.SendBuf(u,1); //PDUType 单字节 01h
clientsocket2.Socket.SendBuf(u,1);//reserved 双字节 01h

h:=74;//h为integer型,占四个字节
clientsocket2.Socket.SendBuf(h,4); //PDU length 四字节

k:=0;//k为word型,占两个字节
clientsocket2.Socket.SendBuf(k,2); //Protocol-version 双字节 0000h
clientsocket2.Socket.SendBuf(k,2); //Reserved 双字节 0000h

str:='emu2';
clientsocket2.Socket.SendBuf(str,16);// Called AE title 16字节

str:='AE_TITLE';
clientsocket2.Socket.SendBuf(str,16);//Calling AE Title 16字节

p:=0; //p为longint 型,占32个字节
clientsocket2.Socket.SendBuf(p,32); //Reserved 32个字节

str:='1.2.804.123456.0.21.4';
clientsocket2.Socket.SendBuf(str,length(str));//Variable items
 
clientsocket2.Socket.SendBuf(u,1); //PDUType 单字节 01h
clientsocket2.Socket.SendBuf(u,1);//reserved 双字节 01h

h:=74;//h为integer型,占四个字节
clientsocket2.Socket.SendBuf(h,4); //PDU length 四字节
type
pbyte=^byte
pword=^word
pint=^integer

p:char;
getmem(p,4);
pbyte(p)^ = $01;
clientsocket2.Socket.SendBuf(p^,1); //PDUType 单字节 01h
pword(p)^ =$01;
clientsocket2.Socket.SendBuf(p^,2);//reserved 双字节 01h

h:=74;//h为integer型,占四个字节
pint(p)^=74;
clientsocket2.Socket.SendBuf(p^,4); //PDU length 四字节
 
那字符串的对吗?

str:='emu2';
clientsocket2.Socket.SendBuf(str,16);// Called AE title 16字节
str:='AE_TITLE';
clientsocket2.Socket.SendBuf(str,16);//Calling AE Title 16字节

str:='1.2.804.123456.0.21.4';
clientsocket2.Socket.SendBuf(str,length(str));//Variable items
 
clientsocket2.Socket.SendBuf(str[1],16);// Called AE title 16字节
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
后退
顶部