Hi,
The function below, GetDeviceName(), is called repeatedly in my application. I
found this is necessary in case the user pulls the ethernet card out of the
laptop. I can repeatedly call this function to poll for when the user puts
the card back in. My application is in constant communication with a device.
Sometimes the device does not reply back in the alloted time and I will call
GetDeviceName() to make sure the device is still valid (card may have been
pulled).
The problem I am seeing is when my application has been running for a many
hours and GetDeviceName() has been called successfully over 32,000 times.
Then the application hangs and I can tell from the logs that it is hanging on
the call to pcap_findalldevs(). Any ideas why?
Thanks,
Tom
function GetDeviceName(const AMacAddress: array of Byte): string;
const
cFuncName = 'GetDeviceName';
var
dev: ppcap_if_t;
devs: ppcap_if_t;
errorbuf: array[0 .. PCAP_ERRBUF_SIZE - 1] of Char;
begin
GLog.LogBegin(cFuncName);
Result := '';
if pcap_findalldevs(@devs, errorbuf) <> 0 then // if error occured
begin
GLog.LogEnd(cFuncName);
Exit;
end;
dev := devs;
while dev <> nil do
begin
if dev.name <> '\Device\NPF_GenericNdisWanAdapter' then
begin
// make sure we can send on this device
if SendBroadcastPacket(AMacAddress, dev.name) then
begin
Result := dev.name;
Break;
end;
end;
dev := dev.next;
end;
pcap_freealldevs(devs);
GLog.LogEnd(cFuncName);
end;
==================================================================
This is the WinPcap users list. It is archived at
http://www.mail-archive.com/[email protected]/
To unsubscribe use
mailto: [EMAIL PROTECTED]
==================================================================