码迷,mamicode.com
首页 > 其他好文 > 详细

采用tidudpserver和tidudpclient进行通讯

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

标签:os   io   for   ar   .net   ad   type   on   

客户端:

      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进行通讯

标签:os   io   for   ar   .net   ad   type   on   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!