I have an application that was written years ago. I'm using Delphi
2007. Its been a few years since the last time I grabbed a cut of the
Indy code. I was needed to update the project for the first time in a
year or more, and I figured I might as well go ahead and get the
latest cut of Indy, as of 2 or 3 days ago anyway. I suppose I should
have left well enough alone and I might go ahead and revert back to
the prior version I was using. But, I'd like to give it a shot to fix
the application if I could.
So, anyway, I did clean build of the Indy solutions, rebuilt my
application, and now the pinging function of my application doesn't
work. I get a socket error 10040.
I did a Google search, and I found a Stack Overflow article where
someone suggested setting the PacketSize down to 24. Remy said that
wasn't a bad idea and a future release of Indy would in fact lower the
PacketSize. But, it didn't help in my case, still get a socket error
10040. I can start up my prior release of my application on the same
machine and ping works fine, no code changes.
Any ideas?
Vote for best question.
Score: 0
# Vote: 0
Date Posted: 5-Apr-2013, at 7:01 PM EST
From: Paul Doland
Re: idIcmpClient ping stopped working after upgrade
Paul wrote:
> So, anyway, I did clean build of the Indy solutions
Indy 9 or 10?
> now the pinging function of my application doesn't
> work. I get a socket error 10040.
Please show your actual code.
10040 is WSAEMSGSIZE, which only applies to UDP sockets. TIdIcmpClient does
not UDP, it uses RAW instead.
> I did a Google search, and I found a Stack Overflow article where
> someone suggested setting the PacketSize down to 24. Remy said
> that wasn't a bad idea and a future release of Indy would in fact lower
> the PacketSize.
It was lowered to 32 on Dec 28 2012.
> But, it didn't help in my case, still get a socket error 10040. I
> can start up my prior release of my application on the same
> machine and ping works fine, no code changes.
Then you can use a packet sniffer, like Wireshark, to compare the raw data
packets being generated by the two apps and see what is actually different
between them.
--
Remy Lebeau (TeamB)
Vote for best answer.
Score: 0
# Vote: 0
Date Posted: 5-Apr-2013, at 7:49 PM EST
From: Remy Lebeau (TeamB)
Re: idIcmpClient ping stopped working after upgrade
In article <565059@forums.embarcadero.com>, nospam@nowhere.com says...
> I get a socket error 10040.
>
>
Hi Paul, this is the text for 10040:
WSAEMSGSIZE (10040) Message too long.
A message sent on a datagram socket was larger than the internal message
buffer or some other network limit, or the buffer used to receive a
datagram into was smaller than the datagram itself.
Jon.
Vote for best answer.
Score: 0
# Vote: 0
Date Posted: 6-Apr-2013, at 12:44 AM EST
From: Jon Tveten
Re: idIcmpClient ping stopped working after upgrade
Registered wrote:
> F8'ing through the code gets the error when the Ping tries
> to execute. It reports Error #10040 Message too long.
That error means the ping reply is larger than the size of the buffer being
used to receive it. That buffer is dynamically allocated based on the size
of the ping request, so the reply should never be larger than the buffer.
I am not able to reproduce this error using the latest Indy 10 SVN snapshot.
I am, however, encountering a range check error when Ping() prepares the
request before sending it. Apparently it is not allocating a large enough
buffer when creating the request. I am troubleshooting that right now.
--
Remy Lebeau (TeamB)
Vote for best answer.
Score: 0
# Vote: 0
Date Posted: 30-Apr-2013, at 10:28 AM EST
From: Remy Lebeau (TeamB)
Re: idIcmpClient ping stopped working after upgrade
I am experiencing the same problem.
I was using XE3 C++ Builder. IndyIPClient170.bpl says it's file version is 17.0.4625.53395
My code
IdIcmpClient1->ReplyStatus->ReplyStatusType = rsError;
IdIcmpClient1->Host = edtPC->Text;
IdIcmpClient1->ReceiveTimeout = 200;
IdIcmpClient1->Ping();
if (IdIcmpClient1->ReplyStatus->ReplyStatusType == rsEcho)
// got reply so do stuff here
else
// no reply - report error
IdIcmpClient1 is an object on the main form ie not created at runtime.
edtPC is just an Edit box that gets a computer name entered into it
Last week I uninstalled XE3 then installed XE4. IndyIPClient180.bpl in the \bin directory reports file version 18.0.4854.59655.
I created a new project directory, copied some of my old projects into this new directory, deleted the Win32 (containing the Debug and Release folders and associated .exe/obj etc files) and __history folders. It recompiled and linked without error. Everything I've tested thus far seems to work fine (although TBH I've only tried a few things), except for this.
F8'ing through the code gets the error when the Ping tries to execute. It reports Error #10040 Message too long.
I still have a copy of the old exe and .dll/bpl from previous version and it continues to work as before.
I too googled the post about setting the Packet Size to 24. I still get the error.
I deleted the design-time object for the IdIcmpClient1 and put a new one on the form. Same error.
Any ideas?
Vote for best answer.
Score: 0
# Vote: 0
Date Posted: 30-Apr-2013, at 12:19 AM EST
From: Registered User
Re: idIcmpClient ping stopped working after upgrade
> {quote:title=Remy Lebeau (TeamB) wrote:}{quote}
> Registered wrote:
>
> > F8'ing through the code gets the error when the Ping tries
> > to execute. It reports Error #10040 Message too long.
>
> That error means the ping reply is larger than the size of the buffer being
> used to receive it. That buffer is dynamically allocated based on the size
> of the ping request, so the reply should never be larger than the buffer.
>
> I am not able to reproduce this error using the latest Indy 10 SVN snapshot.
> I am, however, encountering a range check error when Ping() prepares the
> request before sending it. Apparently it is not allocating a large enough
> buffer when creating the request. I am troubleshooting that right now.
>
> --
> Remy Lebeau (TeamB)
Hi Remy,
I just recently upgraded from XE3 to XE4 and found the exact same problem as the OP. I was able to work-around the problem by using the ABuffer optional parameter of Ping:
[code]
function Ping(Host: String;Timeout: Integer;ShowError: Boolean; out ErrorText: String): Boolean;
var
IdIcmpClient1: TIdIcmpClient;
Reply: TReplyStatusTypes;
ErrorFlag: Boolean;
ABuffer: String;
begin
Result:=False;
ErrorText:='Success';
ErrorFlag:=False;
Reply:=rsEcho;
ABuffer:=Host+StringOfChar(' ',255);
IdIcmpClient1:=TIdIcmpClient.Create;
IdIcmpClient1.PacketSize:=32;
IdIcmpClient1.Host:=Host;
IdIcmpClient1.ReceiveTimeout:=Timeout;
try
try
IdIcmpClient1.Ping(ABuffer);
except
on E: Exception do
begin
ErrorFlag:=True;
ErrorText:=E.Message;
if ShowError then MessageDlg('Ping Error: '+E.Message, mtWarning, [mbOK], 0);
end;
end;
if not ErrorFlag then
begin
try
Reply:=IdIcmpClient1.ReplyStatus.ReplyStatusType;
except
on E: Exception do
begin
ErrorFlag:=True;
ErrorText:=E.Message;
if ShowError then MessageDlg('Ping Reply Error: '+ErrorText, mtWarning, [mbOK], 0);
end;
end;
end;
if not ErrorFlag then
begin
Result:=Reply=rsEcho;
if not Result then
begin
case Reply of
rsEcho: ErrorText:='rsEcho';
rsError: ErrorText:='rsError';
rsTimeOut: ErrorText:='rsTimeOut';
rsErrorUnreachable: ErrorText:='rsErrorUnreachable';
rsErrorTTLExceeded: ErrorText:='rsErrorTTLExceeded';
rsErrorPacketTooBig: ErrorText:='rsErrorPacketTooBig';
rsErrorParameter: ErrorText:='rsErrorParameter';
rsErrorDatagramConversion: ErrorText:='rsErrorDatagramConversion';
rsErrorSecurityFailure: ErrorText:='rsErrorSecurityFailure';
rsSourceQuench: ErrorText:='rsSourceQuench';
rsRedirect: ErrorText:='rsRedirect';
rsTimeStamp: ErrorText:='rsTimeStamp';
rsInfoRequest: ErrorText:='rsInfoRequest';
rsAddressMaskRequest: ErrorText:='rsAddressMaskRequest';
rsTraceRoute: ErrorText:='rsTraceRoute';
rsMobileHostReg: ErrorText:='rsMobileHostReg';
rsMobileHostRedir: ErrorText:='rsMobileHostRedir';
rsIPv6WhereAreYou: ErrorText:='rsIPv6WhereAreYou';
rsIPv6IAmHere: ErrorText:='rsIPv6IAmHere';
rsSKIP: ErrorText:='rsSkip';
else
ErrorText:='Unknown';
end;
if ShowError then MessageDlg('Ping Error: '+ErrorText, mtWarning, [mbOK], 0);
end;
end;
finally
IdIcmpClient1.Free;
end;
end;
[/code]
Is there a better way?
Regards,
Tadeus
Vote for best answer.
Score: 0
# Vote: 0
Date Posted: 16-May-2013, at 7:51 AM EST
From: Tad Adams
Re: idIcmpClient ping stopped working after upgrade
> I just recently upgraded from XE3 to XE4 and found the exact same problem as the OP. I was able to work-around the problem by using the ABuffer optional parameter of Ping:
>
> try
> IdIcmpClient1.Ping(ABuffer);
wow - tried this on my code - changed
IdIcmpClient1->Ping();
to
IdIcmpClient1->Ping(edtPC->Text);
and it now works. Bizarre. Many thx Tad :)
Vote for best answer.
Score: 0
# Vote: 0
Date Posted: 20-May-2013, at 9:42 PM EST
From: Registered User
Re: idIcmpClient ping stopped working after upgrade
> {quote:title=Registered User wrote:}{quote}
> > I just recently upgraded from XE3 to XE4 and found the exact same problem as the OP. I was able to work-around the problem by using the ABuffer optional parameter of Ping:
> >
> > try
> > IdIcmpClient1.Ping(ABuffer);
>
> wow - tried this on my code - changed
>
> IdIcmpClient1->Ping();
>
> to
>
> IdIcmpClient1->Ping(edtPC->Text);
>
> and it now works. Bizarre. Many thx Tad :)
I'm glad it's working for you. I'm still getting occasional errors with it, but it works most of the time. Sometimes I get memory access violations as if some object hasn't been initialized, or the buffer isn't large enough, not sure really.
Best of luck to you.
Tad