再加100!!!!如何使用tsocket的sendbuf和receivebuf????(100分)

  • 主题发起人 主题发起人 g622
  • 开始时间 开始时间
G

g622

Unregistered / Unconfirmed
GUEST, unregistred user!
老爷.太太们....
麻烦给个例子吧!
 
delphi中不是有一个Chart的例子吗?
或者把你想知道的说清楚些 :)
 
我回答的问题里面提供了一个例子,
http://www.gislab.ecnu.edu.cn/delphibbs/DispQ.asp?LID=162604
应该符合你的要求吧
 
server端
unit Unit2;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ScktComp, ExtCtrls, StdCtrls;

type
TForm2 = class(TForm)
Button2: TButton;
Label1: TLabel;
ServerSocket1: TServerSocket;
Label2: TLabel;
Label3: TLabel;
Image1: TImage;
procedure FormCreate(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure ServerSocket1ClientDisconnect(Sender: TObject;
Socket: TCustomWinSocket);
procedure ServerSocket1ClientRead(Sender: TObject;
Socket: TCustomWinSocket);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form2: TForm2;
buf:Array[0..1023] of char;
stm:TMemoryStream;


implementation

{$R *.DFM}

procedure TForm2.FormCreate(Sender: TObject);
begin
serversocket1.Active:=true;
stm:=TMemoryStream.Create;
end;

procedure TForm2.Button2Click(Sender: TObject);
begin
stm.Position:=0;
image1.Picture.Bitmap.LoadFromStream(stm);
end;

procedure TForm2.ServerSocket1ClientDisconnect(Sender: TObject;
Socket: TCustomWinSocket);
begin
stm.SaveToFile('c:/lpp.bmp');
end;

procedure TForm2.ServerSocket1ClientRead(Sender: TObject;
Socket: TCustomWinSocket);
begin
socket.ReceiveBuf(buf,1024);
stm.Write(buf,1024);
end;

end.

clientsocket端
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ScktComp, StdCtrls, ExtCtrls;

type
TForm1 = class(TForm)
ClientSocket1: TClientSocket;
Button1: TButton;
Button2: TButton;
Image1: TImage;
Button3: TButton;
Label1: TLabel;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure ClientSocket1Connect(Sender: TObject;
Socket: TCustomWinSocket);
procedure ClientSocket1Disconnect(Sender: TObject;
Socket: TCustomWinSocket);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
buf:Array[0..1023] of char;
stm:TMemoryStream;

implementation

{$R *.DFM}

procedure TForm1.FormCreate(Sender: TObject);
begin
stm:=TMemoryStream.Create;
stm.LoadFromFile('c:/windows/clouds.bmp');
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
clientsocket1.Address:='172.18.128.182';
clientsocket1.Active:=true;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
clientsocket1.Socket.SendStream(stm);
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
clientsocket1.Active:=false;
end;



end.
 
多人接受答案了。
 
后退
顶部