博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
IdUDPServer中文汉字乱码 及IdTCPClient
阅读量:5308 次
发布时间:2019-06-14

本文共 2339 字,大约阅读时间需要 7 分钟。

 

官网

http://www.indyproject.org/docsite/html/frames.html?frmname=topic&frmfile=TIdTCPServer_OnExecute.html

 

IdUDPServer1中文汉字乱码,用IndyTextEncoding_OSDefault字符编码就解决问题了

IdUDPServer1.Send(1.1.1.1,8080,'中国人',IndyTextEncoding_OSDefault);

 

发送字节

IdUDPServer1.SendBuffer(const System::UnicodeString AHost, const System::Word APort, const Idglobal::TIdBytes ABuffer);

 TIdBytes 就是TBytes就是TByteDynArray

 

 udp bytes byte

procedure TForm1.IdUDPServer1UDPRead(AThread: TIdUDPListenerThread; const AData: TIdBytes; ABinding: TIdSocketHandle);

begin
   lastMsg := BytesToString(AData, IndyTextEncoding_OSDefault);

end;

 

TCP,IdTCPClient

IndyTextEncoding

IdTCPClient1.IOHandler.WriteLn(sendData,IndyTextEncoding(TEncoding.ANSI)); 

 

bs:TBytes;

setlength(bs,8);

IdTCPClient1.IOHandler.Write(TIdBytes(bs));

 

c++

String rstr = BytesToString(AData, IndyTextEncoding_UTF8());

https://stackoverflow.com/questions/13839094/how-to-read-all-bytes-from-server-using-indy-client-in-delphi

https://forums.embarcadero.com/thread.jspa?threadID=211952

 

 

IdTCPClient1->Host =GStack->LocalAddress;;

    IdTCPClient1->Port = 9080;
    IdTCPClient1->Connect();

 

 

TCP发送buff

TFileStream *fs;String FilePath=”c:\\test.data";fs = new TFileStream(fileNamePath, fmOpenRead); IdTCPClient1->IOHandler->WriteBufferOpen();               IdTCPClient1->IOHandler->WriteLn(fileName);               IdTCPClient1->IOHandler->Write(fs,false,True);               delete fs;               IdTCPClient1->IOHandler->WriteBufferClose();

TCP接收buff

void __fastcall TFrmServer::IdTCPServer1Execute(TIdContext *AContext) {
TFileStream *fs; try {
FileName = AContext->Connection->IOHandler->ReadLn("",0); } catch(...) { return; } if( FileName.IsEmpty() ) return; FileNew = DataFilePath + FileName; fs = new TFileStream(FileNew, fmCreate); AContext->Connection->IOHandler->ReadStream (fs,-1,false); delete fs; //新版没有这个线程函数了   //AContext->Connection->Synchronize(frmksjg->BitBtn1->Click); }

 

https://stackoverflow.com/questions/10361446/delphi-indy-10-demo-application-client-server

https://stackoverflow.com/questions/25438309/indy10-idtcpclients-iohandler-send-additional-data

https://stackoverflow.com/questions/25438309/indy10-idtcpclients-iohandler-send-additional-data

https://forums.embarcadero.com/thread.jspa?threadID=115603

转载于:https://www.cnblogs.com/cb168/p/4006994.html

你可能感兴趣的文章
从零搭建cortex-m0 UART工程
查看>>
Nuxt.js知识点
查看>>
Java 日期类 Calendar SimpleDateFormat
查看>>
[2018.4.2集训]b-容斥-计数
查看>>
什么是以及为什么,要把大型Web项目系统逻辑分层和物理分层?
查看>>
redis源码阅读笔记----dict.c
查看>>
MyBatis基础入门《五》核心配置文件
查看>>
不定参数的应用
查看>>
day2-2.6三级菜单 (字典)
查看>>
python 从0学起
查看>>
WPF验证之——必填验证
查看>>
如何更有效地学习开源项目的代码?
查看>>
@UniqueConstraint
查看>>
.Net面試4套
查看>>
jsp异常 The JSP specification requires that an attribute name is preceded by whitespace
查看>>
关于这几天学爬视频链接的一些感想
查看>>
Revit安装失败怎样卸载重新安装Revit,解决Revit安装失败的方法总结
查看>>
Java实现按字节长度截取字符串的方法
查看>>
Linux下/proc目录简介(文章来源于http://blog.csdn.net/zdwzzu2006/article/details/7747977)...
查看>>
BeanUtils.copyProperties()拷贝属性时,忽略空值
查看>>