关于Indy Tcpserver和Tcpclient

litelwang 2005-04-06 09:03:46
用了Indy以后我不担心多线程的问题。我的客户端和服务器端需要多次传送不同性质的数据,所以服务器端是否要使用循环代码读取客户端的内容?客户端通过发送不同的前缀让服务器知道并接收其后的数据。请高手解答。
...全文
135 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
litelwang 2005-04-15
  • 打赏
  • 举报
回复
谢谢,测试完毕立即给分。
vinsonshen 2005-04-06
  • 打赏
  • 举报
回复
up
2312 2005-04-06
  • 打赏
  • 举报
回复
procedure TMainFrm.IdTCPServerExecute(AThread: TIdPeerThread);
var
MyRec : ClientWareRecord;
SourceBmp : TBitmap;
fbuf1:TMemoryStream;
LibHandle: THandle;
Jpg:Tjpegimage;
protsTmp,strmypath,strMyip:string;
ShowCalendar:Procedure(SourceBmp: TBitmap; Width, Height: Integer; JpgPath :string);
Com, // System command
Msg,sTmp : String;
begin
AThread.connection.ReadBuffer(MyRec,SizeOf(MyRec));
if MyRec.ClientComType = MP_GETTBMPTOTJPG then
begin

try
SourceBmp := TBitmap.Create;
SourceBmp.PixelFormat := pf24bit;
SourceBmp.LoadFromFile(MyRec.ServerPath);
jpg := TJPEGImage.Create;
jpg.Assign(SourceBmp);
//jpg.SaveToFile(JpgPath);
//===================================================================
fbuf1:=TMemoryStream.Create;
//===================================================================
jpg.SaveToStream(fbuf1);
SourceBmp.FreeImage;
FreeAndNil(SourceBmp);
FreeAndNil(jpg);
AThread.Connection.OpenWriteBuffer;
AThread.Connection.Writestream(fbuf1,true,false);
finally
AThread.Connection.CloseWriteBuffer;
end;
end;
end;

1,593

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 网络通信/分布式开发
社区管理员
  • 网络通信/分布式开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧