I work for a company that uses Raw ethernet frames to control hardware. I'm trying to find a way to send the frames and also receive them. I've gotten a little lost trying to use npcap to do this and I'm wondering if Indy has the capability to do this.
As a clarification: I just need it to send a frame of [send to MAC][sent from MAC][etc.......]
Hello,
I'm just trying new 15.5.2 version that resolved some issues.
I use Delphi 10.2 Tokyo.
Going forward on my tests, I noticed that, when I compile in 64-bit platform, the function StrUtils.PosEx doesnt'work properly.
(I don't call it directly, but it's used (for example) in System.IOUtils (TPath, TDirectory, TFile)).
By example:
PosEx(':','C:\SVN\Mydirectory',3) return 2 (that is the right value if I call PosEx(':','C:\SVN\Mydirectory',1))
while it must return 0 (as 32-bit does).
Also notes that in a normal vcl application (no-intraweb) it works in 64-bit too.
Perhaps it depends by some directive but I wasn't able to find it.
Is is possible to add attribute to <html> or <body> tag? and change it at runtime
For example
IWForm1.AddAttribute('data-mode="edit"');
>>>>
<html data-mode="edit"> or <body data-mode="edit">
I have a serious problem and I can't find any information.
I have a service made with Delphi and Indy 10. I made it with TIdTCPServer.
It's a service that controls licenses with a "keep alive". Everything is based using the TIdTCPClient that runs the applications, exchanging information with the server service.
They always exchange XML based structures, like text. In this XML, there is a "command" property. This property receives every 15 minutes the command
"Keep" and the server answers "ok, here I am, Keep ok" and gives to the station that runs my application, status and login information.
All the information is stored in memory in a structure based on Tlist<Types>.
We know that there are threads that are executed in the TidTCPExecute event for each connection.
In my services there are another parallel threads inside the service, to maintain it, renew licenses and clean up unused licenses.
Everything accesses structures based on that Tlist<Lot of Types>. There are of course, other data sharewd by all those threads.
Everything works ok.
But...
Here comes the problem. My application disconnects randomly, to some workstations. I suspect it must be because of the way I protect the structures and data shared by the threads.
Going in detail
We have the IdTCPServerExecute event
Code:
var
ClientIPAddr: string;
begin
if not Server.Active then
exit;
ClientIPAddr := AContext.Binding.PeerIP; //ip
xComando.Linea := fxLeerLinea; //read the line
if xComando.Linea = '' then
begin
LimpiamosBuffer(AContext); //clean up buffer
exit;
end;
xComando.EsXML := fxEsXML( xComando.Linea ); //is an xml what is coming
if xComando.EsXML then
TManejoPaquetesDOM.Procesa( xComando.Linea, Acontext, Server ) //process de estructure and comand. See below
else
begin
TumbarIP(ClientIPAddr); //clean the connection
exit;
end;
xComando.Linea := ''; //clean line
end;
The "TManejoPaquetesDOM.Procesa( xComando.Linea, Acontext, Server )" is a class like this
public
constructor Crear(linea: string; AContext: TIdContext; pServer: TidTCPServer );
class procedure Procesa(Linea: string; AContext: TIdContext; pServer: TidTCPServer );
end;
The "DoSynchronize" does all the work with each connection receive from clients.
Code:
class procedure TManejoPaquetesDOM.Procesa(Linea: string; AContext: TIdContext; pServer: TidTCPServer );
// with this class procedure we manage the thread
begin
with Crear(linea, AContext, pServer ) do
try
Synchronize;
finally
Free;
end;
end;
//the constructor creates, passes the data and parses the XML that brings each station
constructor TManejoPaquetesDOM.Crear(linea: string; AContext: TIdContext; pServer: TIdTCPServer );
begin
inherited Create;
fLinea := linea;
FServer := pServer;
FDespacho := TomaObjXML( linea );
end;
As you can see, "TManejoPaquetesDOM = class(TIdSync)". This is who processes everything. As I understand it, TidSync makes all the other threads
of IdTCPServerExecute threads wait for it to finish.
I'm not sure if this is the best approach, ideally the process should be parallel without making anyone wait.
All the structures when accessed by the other threads of my application are protected with a generic class I made
like this
Code:
TControlBloqueos = class
private
FLlave: TCriticalSection;
public
constructor Create;
destructor Destroy; override;
procedure Lock;
procedure Unlock;
end;
implementation
constructor TControlBloqueos.Create;
begin
inherited;
FLlave := TCriticalSection.Create;
end;
destructor TControlBloqueos.Destroy;
begin
Fllave.Free;
inherited;
end;
procedure TControlBloqueos.Unlock;
begin
Fllave.Leave;
end;
procedure TControlBloqueos.Lock;
begin
Fllave.Enter;
end;
Each time the data shared by threads are accessed, those threads protect the data with an instance of this class, global to the whole service.
This instance is created at the start of the service
Code:
Bloqueo := TControlBloqueos.Create;
and all the threads accessing the data, proceed like this.
Code:
Bloqueo.lock;
try
//process shared data between threads
finally
Bloqueo.unlock;
end;
My problem is that I can't detect those random disconnections of some users from my system.
My questions
a) Is there a way to speed up what IdTCPServerExecute does? Not using TidSync?
b) What is the best way to protect shared data between threads? I'm not sure what I did is the best approach.
I use timeout template file(IWSessionTimeout.html) in my Templates folder. I test on my local computer by myapp.exe (indy), It show timeout page normally. But I built to myapp.dll and used on my server by IIS. When Timeout occurs, it doesn't show the timeout page, but shows Server Error : 500 - Internal server error instead (There is a problem with the resource you are looking for, and it cannot be displayed.).
I don't know if for ISAPI there needs to be any additional adjustments or not in order to display the Timeout template page when a Timeout occurs because for Indy it displays normally.
Hello i tried to read email with idimap indy on lazarus but i get this error..
unable to execute command wrong connection state, current connection state authenticated
procedure TFormMain.getunreademails(Sender: TObject);
Var lj,i,id,attachs:Integer;
CurrUId:String;
msg: TIdMessage;
BodyTexts: TStringList;
lParts:TIdImapMessageParts;
SearchInfo: array of TIdIMAP4SearchRec;
begin
// if( IdIMAP.Connected=false) then begin
// IdIMAP.Disconnect();
// sleep(200);
// IdIMAP.Connect();
// FolderList:= TStringList.Create;
// IdIMAP.StatusMailBox('Inbox', IdIMAP.MailBox);
// IdImap.ListMailBoxes(FolderList);
// IdImap.SelectMailBox('Inbox');
// end;
if(IDIMAP.Connected=false) then begin;
SetLength(SearchInfo, 1);
SearchInfo[0].SearchKey := skUnseen;
IDIMAP.UIDSearchMailBox(SearchInfo);
end else begin
SetLength(SearchInfo, 1);
SearchInfo[0].SearchKey := skUnseen;
IDIMAP.UIDSearchMailBox(SearchInfo); // here is generated the error
end;
lParts := TIdImapMessageParts.Create(nil);
if( IDImap.Connected=true) then begin
for i := 0 to High(IDIMAP.MailBox.SearchResult) do begin
MSG := TIdMessage.Create(nil);
Id:=IDIMAP.MailBox.SearchResult[i];
CurrUId:=Inttostr(IDIMAP.MailBox.SearchResult[i]);
try
if( not BdEmails.Locate('UID', currUID , [loCaseInsensitive])) then begin
IDIMAP.UIDRetrieve( CurrUID, msg );
IDImap.UIDRetrieveStructure(Inttostr(IDIMAP.MailBox.SearchResult[i]), lParts);
attachs:=0;
for lj := 0 to msg.MessageParts.Count - 1 do begin
if msg.MessageParts.Items[lj] is TIdAttachment then begin
if( lParts[lJ].FileName <>'') then begin
Inc(attachs);
IDImap.UidRetrievePartToFile(Inttostr(IDIMAP.MailBox.SearchResult[i]), lParts[lJ].ImapPartNumber, i , Path+'emails\attach\'+lParts[lJ].FileName, lParts[lJ].ContentTransferEncoding);
BDAttachs.Append;
BDAttachs.FieldByName('Account').AsString :=BDAcct.FieldByName('emailAcc').AsString ;
BDAttachs.FieldByName('ID').AsInteger :=id ;
BDAttachs.FieldByName('UID').AsString := CurrUID;
BDAttachs.FieldByName('Attachs').AsInteger := lj;
BDAttachs.FieldByName('FileName').AsString := lParts[lJ].FileName;
BDAttachs.post;
end;
end;
end;
// fileName_MailSource := TmpFolder + Inttostr(IDIMAP.MailBox.SearchResult[i])+ '.eml';
BDEmails.Append;
BDEmails.FieldByName('Account').AsString := BDAcct.FieldByName('emailAcc').AsString;
BDEmails.FieldByName('ID').AsInteger := id;
BDEmails.FieldByName('UID').AsString := currUID ;
BDEmails.FieldByName('Date').AsDateTime := msg.Date;
BDEmails.FieldByName('subject').AsString := msg.Subject;
BDEmails.FieldByName('attachs').AsInteger := attachs;
BDEmails.FieldByName('fromaddr').AsString := msg.From.Address;
BDEmails.post;
end;
finally
MSG.Free;
end;
end;
end;
BDEmails.First;
end;
some examples to read unseen emails.... still using query search,.. or what i need to change to get that...
I have multiple iwframes, using them as a body of my page beside a header and a footer. everything is working great until I decided to use IWTemplateProcessorHTML.
My problem is that each iwframe has a IWFrameRegion which cannot be renamed for some reasons (I don't know why), although I tried to rename it various ways however it's not renamable! for that it's impossible to apply a template for each iwframe because it will have the same file name IWFrameRegion.html therefor it will work only for one iwframe only!
Another try was by adding another IWRegion and then easily rename it after that applying the IWTemplateProcessorHTML on it but in the end, it renders nothing! (empty page).
Hence, this is how I call the iwframe to display it inside the body region:
if frm1 = nil then
begin
frm1 := TIWFrame2.Create(self);
frm1.Parent := IWRegion1;
frm1.Visible := true;
end;
So how to solve this issue? is my approach wrong? or there is another way to apply IWTemplateProcessorHTML to an iwframe?