asked on
procedure TIndyTCPServer.InitServer;
begin
FServerType := 'TCP';
FServer := TIdTCPServer.Create(nil);
with FServer do begin
MaxConnections := FMaxConnections;
DefaultPort := DEF_TCP_PORT;
//TerminateWaitTime := 2000;
OnConnect := ServerSocketConnect;
OnDisconnect := ServerSocketDisconnect;
OnExecute := ServerSocketExecute;
end;
end;
procedure TIndyTCPServer.CloseServer;
begin
StopServer;
FServer.Free;
end;
procedure TIndyTCPServer.StartServer;
begin
FServer.Active := True;
end;
procedure TIndyTCPServer.StopServer;
var
Threads: TList;
i: Integer;
begin
try
Threads := FServer.Threads.LockList;
try
for i := Threads.Count - 1 downto 0 do
with TIdPeerThread(Threads.Items[i]).Connection do
if Connected then
Disconnect;
finally
FServer.Threads.UnlockList;
end;
FServer.Active := False;
except
end;
end;
procedure TIndyTCPServer.TransmitBuffer(Connection: TObject; Buffer: Pointer; Count: Integer);
begin
with TIdPeerThread(Connection) do
if not Terminated and Connection.Connected then begin
Connection.Socket.UseNagle:=False; // TCP NO_DELAY!
Connection.WriteBuffer(Buffer^, Count, True);
end;
end;
procedure TIndyTCPServer.ServerSocketConnect(AThread: TIdPeerThread);
begin
// Save for easy access later
AThread.Connection.Socket.UseNagle:=False; // TCP NO_DELAY!
AThread.Data := AddRemote(AThread, AThread.Connection.Socket.Binding.PeerIP);
end;
procedure TIndyTCPServer.ServerSocketDisconnect(AThread: TIdPeerThread);
begin
DeleteRemote(TRemote(AThread.Data));
AThread.Data := nil;
end;
ASKER
ASKER
Delphi is the most powerful Object Pascal IDE and component library for cross-platform Native App Development with flexible Cloud services and broad IoT connectivity. It provides powerful VCL controls for Windows 10 and enables FMX development for Windows, Mac and Mobile. Delphi is your choice for ultrafast Enterprise Strong Development™. Look for increased memory for large projects, extended multi-monitor support, improved Object Inspector and much more. Delphi is 5x faster for development and deployment across multiple desktop, mobile, cloud and database platforms including 32-bit and 64-bit Windows 10.
TRUSTED BY
Perhaps this may help...
Indy Write Buffering / Efficient TCP communication