Home > Back-end >  Ask a question about idcmpClient, ping host feedback 'always the allocate a socket'
Ask a question about idcmpClient, ping host feedback 'always the allocate a socket'

Time:09-27

Online, such as the great god answer
Main problems: the younger brother using Delphi + SQL programming, before connect to the server database, want to ping the host in order to reduce the feedback time software (if the IP address error, can lead to landing software interface for a long time without response), before use code no problem under XP system, can run successfully, now in the computer, the same code to run when EIDInvalidSocket with message 'always the allocate a socket, please help to see what is causing the great god, thank you for the great god first here,
The code is as follows:
IpAddress:=edit3. Text;
IdIcmpClient1. Host:=IpAddress;//the server name or IP address
IdIcmpClient1. ReceiveTimeout:=1000;//maximum wait time
IdIcmpClient1. Ping ();
if (IdIcmpClient1 ReplyStatus. BytesReceived=0) or (IdIcmpClient1. ReplyStatus. TimeToLive=0) then
Application. MessageBox (' the server address is not correct or server is not open, contact your network administrator. ', ' ', MB_OK)
The else
The begin
SaleDM. ADOConnection1. Connected:=false;
SaleDM. ADOConnection1. LoginPrompt:=false;
SaleDM. ADOConnection1. The ConnectionString:='Provider=SQLOLEDB. 1; Persist Security Info=False; User ID='+' prmUser '+'. Password='+' also '+'.='+' Initial Catalog Tsddsjk '+'. Data Source='+ IpAddress;
Try SaleDM. ADOConnection1. Connected:=true;
Except,
Application. The MessageBox (' database configuration is not correct, please reconfigure! ', 'prompt', MB_OK);
SaleDM. ADOConnection1. Connected:=false;
Application. The Terminate;
end;
end;
Problems appeared in the red words part, after IdIcmpClient1 function part {}, program can run,

CodePudding user response:

Meet the Socket. Exe?

CodePudding user response:

LS a great god can say in detail? Still don't know much about the socket. Exe is what mean? Under XP system can run before, now not Windows 7, related to system?
Can said in detail how to solve?

CodePudding user response:

@ lyhoo163 great god come and problem still bothers me

CodePudding user response:

New situation description: to build a blank form, other test statement if there is a problem, the code is as follows:
IdIcmpClient1. Host:=Edit1. Text;
IdIcmpClient1. ReceiveTimeout:=1000;
IdIcmpClient1. Ping ();
If (IdIcmpClient1. ReplyStatus. BytesReceived=0) or (IdIcmpClient1. ReplyStatus. TimeToLive=0) then
Label1. Caption:='failure'
The else
Label1. Caption:='success';
Under new condition, the program runs fine, prove that the statement should be no problem, but after saved to local (save all), and then run, and then there 'always the allocate a socket,'
What a great god also met?

CodePudding user response:

I also encountered this problem set EXE file compatibility for XP can

Why on Windows 7/doing no specific also don't know

CodePudding user response:

Windows 7 permissions problem?

You turn off the firewall, and then try to use administrator privileges to run
  • Related