请教delphi7.0中的TcpServer的onAccept事件的用法,多谢指点!(50分)

  • 主题发起人 主题发起人 cxfirefox
  • 开始时间 开始时间
C

cxfirefox

Unregistered / Unconfirmed
GUEST, unregistred user!
请问delphi7.0中的tcpServer的onaccept事件什么时候触发,我下面的这个程序,发送了两次数据,但是只触发了一次,为什么啊?
procedure TForm1.Button1Click(Sender: TObject);
var Temp:Tbitmap;
TempJpg:TJpegimage;
imgSize,s:String;
begin
if OpenPictureDialog1.Execute then
begin
Temp:=TBitmap.Create;
TempJpg:=TJpegimage.Create;
try
Temp.LoadFromFile(OpenpictureDialog1.FileName);
Tempjpg.Assign(Temp);
Tempjpg.CompressionQuality:=10; //压缩率
Tempjpg.SaveToStream(imgStreamSent);
finally
Temp.Free;
end;
end;
TcpClient1.RemoteHost:=edtRemoteHost.Text;
TcpClient1.RemotePort:=edtRemotePort.Text;
if edtRemotePort.Text <>edtLocalport.Text then
showmessage('端口不匹配');
if TcpClient1.Connect then
begin

//Tempjpg.Free;
imgStreamSent.Position:=0;
imgSize:=intToStr(imgStreamSent.Size);
TcpClient1.Sendln(imgSize); //第一次发送
//等待通知传送
s:=TcpClient1.Receiveln;
while not (s = 'Ready for Image' ) do
s:=TcpClient1.Receiveln;

TcpClient1.Sendln('haha'); //第二次发送

//imgStreamSent.Position:=0;
//TcpClient1.SendStream(imgStreamSent);
//TcpClient1.Disconnect;

end;
end;

procedure TForm1.TcpServer1Accept(Sender: TObject;
ClientSocket: TCustomIpClient);
var Tempimg:TBitmap;
Tempjpg:TJpegimage;
s:String;
OneFrameSize:Integer;
RevBuffer:array[1..1024] of byte;
begin
//accept事件是什么触发的?
s:=ClientSocket.Receiveln;
if Revimg=false then
begin

RevSize:=StrToInt(s);
while (RevSize=0) do
RevSize:=StrToInt(ClientSocket.Receiveln);
Revimg:=true;
ClientSocket.Sendln('Ready for Image');
end else
begin
……
Revimg:=false;
end;
end;
 
后退
顶部