有没有采用ctBlocking方式收数据的ClientSocket的例子,急需,要测试通过的

wolf2005 2004-06-09 10:49:19
有没有采用ctBlocking方式收数据的ClientSocket的例子,急需,要测试通过的
...全文
148 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
outer2000 2004-09-22
  • 打赏
  • 举报
回复
This example shows the execute method of a thread used to send requests to a server over a socket connection:

procedure TMyClientThread.Execute;

var
TheStream: TWinSocketStream;
buffer: string;
begin
{ create a TWinSocketStream for reading and writing }
TheStream := TWinSocketStream.Create(ClientSocket1.Socket, 60000);
try
{ fetch and process commands until the connection or thread is terminated }
while (not Terminated) and (ClientSocket1.Active) do
begin
try
GetNextRequest(buffer); { GetNextRequest must be a thread-safe method }

{ write the request to the server }
TheStream.Write(buffer, Length(buffer) + 1);
{ continue the communication (eg read a response from the server) }
...
except
if not(ExceptObject is EAbort) then
Synchronize(HandleThreadException); { you must write HandleThreadException }
end;
end;
finally
TheStream.Free;
end;
end;
outer2000 2004-09-22
  • 打赏
  • 举报
回复
DEPHI本身帮助里就DEMO啊;
wolf2005 2004-09-22
  • 打赏
  • 举报
回复
散分,不要吗?
linzhengqun 2004-09-13
  • 打赏
  • 举报
回复
看看这篇文章,希望对你有帮助:
http://www.nssoft.net/delphihelp.asp
wolf2005 2004-09-13
  • 打赏
  • 举报
回复
分分了,快来顶
耙子 2004-06-09
  • 打赏
  • 举报
回复
我从前是看着帮助写的。她的帮助提供的构详细了,还有代码例子。

5,392

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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