procedure TForm1.SpeedButton1Click(Sender: TObject); begin udp.Send(‘localhost‘, 1234, ‘abc123‘); // 发送字符, 这样发中文接收方会乱码 end; procedure TForm1.SpeedButton2Click(Sender: TObject); var b: TBytes; s: string; begin s := ‘你好‘; b := BytesOf(s); udp.SendBuffer(‘localhost‘, 1234, TIdBytes(b)); // TIdBytes要引用IdGlobal.pas单元 end;
原文:http://www.cnblogs.com/studypanp/p/5051986.html