Home > Back-end >  O socket error 10054 solutions
O socket error 10054 solutions

Time:10-19

Before I use delphi2010 + indy10 develop communications software, reference example for the client to the server to send information to normal, but after reshipment system, the client connection was successful, but send information appears socket error 10054, as far as the client send the data to the server will report the error, the Internet didn't solve a lot of, not because of the firewall,
The server code is as follows:
Procedure TForm1. FormCreate (Sender: TObject);
Var myini: Tinifile;
Filename: the string;
IP, port: string;
The begin
Filename:=ExtractFilePath (Paramstr (0)) + 'deploy. Ini';
Myini:=Tinifile. Create (filename);
IP:=myini Readstring (' deploy ', 'IP', '1');
Port:=myini. Readstring (' deploy ', 'port', '2');
If IP='1' then
The begin
Application. MessageBox (' IP address undefined ', 'warning' MB_ICONWARNING);
Application. The Terminate;
end;
If the port='2' then
The begin
Application. MessageBox (' port undefined ', 'warning', MB_ICONWARNING);
Application. The Terminate;
end;
With IdTCPServer1. Bindings. Add the do
The begin
IP:=IP;
Port:=Port;
end;
Idtcpserver1. OnExecute:=IdTCPServer1Execute;
Memo1. Lines. The Clear;
Myini. Free;
end;

Procedure TForm1. FormShow (Sender: TObject);
The begin
IdTCPServer1. Active:=true;
end;

Procedure TForm1. IdTCPServer1Execute (AContext: TIdContext);
Var Swp: String;
The begin
Try
AContext. Connection. IOHandler. CheckForDisconnect (True, True);
Swp:=AContext Connection. The IOHandler. ReadLn ();
If (Swp<& gt; ") then
AContext. Connection. IOHandler. WriteLn (' server have received your message: '+ Swp);
Memo1. Lines. The Add (Swp);
The finally
end;
end;
The client code is as follows:
Procedure Tloginform. Button2Click (Sender: TObject);//connection
The begin
Try
If not (dm) DataModule1) IdTCPClient1. Connected) then
The begin
Dm. DataModule1. IdTCPClient1. Connect;
Dm. DataModule1. IdTCPClient1. IOHandler. Writeln (' lianjie);
ShowMessage (' successful connection);
end;
Except,
ShowMessage (' connection ');
end;
end;

Procedure Tloginform. Button4Click (Sender: TObject);//send information
Var
Str: String;
The begin
Str:=Edit1. Text;
If (dm) DataModule1) IdTCPClient1. Connected) then
Dm. DataModule1. IdTCPClient1. IOHandler. Writeln (Str);
end;
The data module code (idtcpclient on data module) :
Procedure TDataModule1. DataModuleCreate (Sender: TObject);
Var myinifile: Tinifile;
Filename: the string;
The begin
Filename:=ExtractFilePath (Paramstr (0)) + 'cdeploy. Ini';
Myinifile:=Tinifile. Create (filename);
IP:=myinifile Readstring (' deploy ', 'IP', ');
Port:=myinifile. Readstring (' deploy ', 'port', ');
Servername:=myinifile Readstring (' deploy ', 'servername', ');
SocketConnection1. Address:=IP;
SocketConnection1. ServerName:='Project1. Myproject';
SocketConnection1. ServerGUID:='{5 d6a3395-4613-41 e1 - e71caaf85a1 ABDF - 1}'.
ClientDataSet1. RemoteServer:=SocketConnection1;
ClientDataSet1. ProviderName:='DataSetProvider4';
Idtcpclient1. Port:=strtoint (Port);
Idtcpclient1. Host:=IP;
If ip<& gt; "' then
The begin
SocketConnection1. Connected:=true;
end;
Myinifile. Free;
end;

CodePudding user response:

A connection is reset, a connection is established to the remote host forcibly closed, if the process terminates abnormally running on the remote host (due to the memory conflict or hardware failure), or for socket carried out forcibly closed at a time, will generate a 10054 error.

CodePudding user response:

This I know, but the code is only so much, I don't know where is wrong, only know the reason but not solve,,,

CodePudding user response:

For help, the best!!!!!

CodePudding user response:

Has also had the same problem, I don't know how to solve, I wonder if the original poster is solve this problem? If settled, please do not hesitate to comment, thank you.
  • Related