首页 > 其他 > 详细

采用tidudpserver和tidudpclient进行通讯

时间:2014-08-14 13:33:28      阅读:605      评论:0      收藏:0      [点我收藏+]

客户端:

      client.Host:=‘192.168.0.104‘;
      client.Port:=8010;
      client.Send(‘abc‘);

 

服务端:

procedure Tudpform.myudpserverUDPRead(AThread: TIdUDPListenerThread;   const AData: TIdBytes; ABinding: TIdSocketHandle); var  stream:tmemorystream;  total1,curpak,sumpak:word;  filetype:integer;  fileindex:integer;  str:string;  sdata:tidbytes;  abd:TIdSocketHandle; begin   inc(total);   tempbinding:=abinding;

  curpak:=adata[7]*256*256*256+adata[8]*256*256+adata[9]*256+adata[10];   sumpak:=adata[11]*256*256*256+adata[12]*256*256+adata[13]*256+adata[14];   caption:=format(‘total:%d,sumpak:%d,curpak:%d‘,[total,sumpak,curpak]);

  stream:=tmemorystream.Create;   stream.Write(adata[0],high(adata)+1);   udpclients.netdata.AddDatas(athread.Binding.PeerIP,athread.Binding.PeerPort,stream);   setlength(sdata,4);   sdata[0]:=48;   sdata[1]:=49;   sdata[2]:=50;   sdata[3]:=51;   myudpserver.binding.assign(abinding);   abinding.SendTo(abinding.PeerIP,abinding.PeerPort,sdata);

  //myudpserver.SendBuffer(abinding.PeerIP,abinding.PeerPort,sdata);   //udpclients.ProcessUdpData(athread,adata,abinding);

end;

采用tidudpserver和tidudpclient进行通讯,布布扣,bubuko.com

采用tidudpserver和tidudpclient进行通讯

原文:http://www.cnblogs.com/HuiLove/p/3912076.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!