现在有服务器向客户端连续发送N条消息,我在客户端要开启线程来接收,请大家给个客户端开启线程,接受消息的例子啊,小弟感激不尽!!
解决方案 »
- 怎么样在DBGridEh行直接显示图片?
- 用TWebConnection启动的应用服务器端怎么读写注册表?
- String与Word类型进行比较。100分
- 如何在SQL SERVER2000中存储word 文件和图片????
- 关于数据库帮定的问题
- 我的程序在没装过dephi的机器上运行不了,请问该怎么办?
- 简单问题,请指教!
- 关于spinedit的问题
- 请问如何使listview中的columns中的Caption所显示的字居中?
- 网络双绞线内有8小根,究竟起作用的有几根?
- dbcombobox可不可以实现这种功能,或是其它控件可以实现这个功能吗?在线等!
- 如何自动生成Delphi多层数据库应用项目全部源代码
var
ires,i,j : integer;
recMsg : TMyMsg;
stmp,tmpName,tmpRealName,tmpDept,pointDept : String;
sNode,ss : TTreeNode;
begin
{ Place thread code here }
FreeOnTerminate := True; while ((not Terminated) and DM.tcpLog.Connected) do
begin
ires := DM.tcpLog.ReadFromStack; //........
if ires > 0 then
begin
DM.tcpLog.ReadBuffer(recMsg,sizeof(recMsg));
...
接收的方法很多,自己选择
TClientHandleThread = class(TThread)
private
CB: string;
procedure HandleInput;
protected
procedure Execute; override; end;procedure TClientHandleThread.Execute;
begin
inherited;
while not Terminated do
begin
try
Application.ProcessMessages;
CB := UDPMainForm.UDPClient.ReceiveString();
Synchronize(HandleInput);
except
end;
end;
end;procedure TClientHandleThread.HandleInput;
begin
if Trim(CB) <> '' then
UDPMainForm.mmoRecive.Lines.Add(FormatDateTime('yyyy-mm-dd hh:mm:ss', Now)
+',收到服务器发来的消息:' +cb);
end;