请问如何做客户端和服务端的连接 如何做多线程 delphi7

ou630j 2009-02-26 03:19:22
现在我有一个服务端,一个客户端程序,delphi7

1请问如何从服务端发信息给客户端
1假设我要发送文件
2发送信息 temp

2客户端怎么发信息给服务端
发送信息 temp

3如果有多个客户端,怎么做多线程,请问用什么控件?

希望能提供代码(分不够再加)
...全文
181 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
yct0605 2009-02-27
  • 打赏
  • 举报
回复
“kampan”的代码已经给了啊,不错啊,参考一下吧!
zhaozhen2004 2009-02-26
  • 打赏
  • 举报
回复
indy.
ou630j 2009-02-26
  • 打赏
  • 举报
回复
怎么都说得那么容易,能不能给点详细的代码啊
alanhao 2009-02-26
  • 打赏
  • 举报
回复
使用internet下的ClientSocket和Serversocket实现
create it
ou630j 2009-02-26
  • 打赏
  • 举报
回复
那怎么连接的?
bdmh 2009-02-26
  • 打赏
  • 举报
回复
发消息,给客户端ip呀,发送的消息,先把规则定好,哪段代表指令,哪段代表内容等等,接收方解析接收到的字符即可,根据指令就可以做任何的事情了
tsingfeng_bhcss 2009-02-26
  • 打赏
  • 举报
回复
安装Delphi后Demos目录下就有
kampan 2009-02-26
  • 打赏
  • 举报
回复
客户端:

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, jpeg, ExtCtrls, IdBaseComponent, IdComponent, IdTCPConnection,
IdTCPClient, StdCtrls, Buttons;

type
TForm1 = class(TForm)
Button1: TButton;
IdTCPClient1: TIdTCPClient;
Image1: TImage;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
temp:tmemorystream;
begin
temp:=tmemorystream.Create;
self.Image1.Picture.Graphic.SaveToStream(temp);
self.IdTCPClient1.Connect();
self.IdTCPClient1.WriteStream(temp);
self.IdTCPClient1.Disconnect;
temp.Free;
end;

end.

kampan 2009-02-26
  • 打赏
  • 举报
回复
服务器:
 
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, IdBaseComponent, IdComponent, IdTCPServer, ExtCtrls, StdCtrls,
Buttons, jpeg;


type
TForm1 = class(TForm)
IdTCPServer1: TIdTCPServer;
Image1: TImage;
procedure IdTCPServer1Execute(AThread: TIdPeerThread);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.IdTCPServer1Execute(AThread: TIdPeerThread);
const
tempimagefile='c:/test.jpg';
var
t:tmemorystream;
begin
t:=tmemorystream.Create;
athread.Connection.ReadStream(t,-1,true);
t.SaveToFile(tempimagefile);
self.Image1.Picture.LoadFromFile(tempimagefile);
t.Free;
end;

end.



ou630j 2009-02-26
  • 打赏
  • 举报
回复
还有,接收到信息怎么触发程序

5,388

社区成员

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

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