1. What are the major differences between in Indy components and the
Delphi VCL components as far as TCP/IP Sockets and specifically
servers are concerned?
2. Has anyone her converted existing TServerSocket code to an Indy
component? If so, which component(s) did you choose? Why did you
choose to do so? And what tips would you have for someone attempting
the same feat?
Thanks,
Kimberly
major difference is that Indy does not detect that a client has
disconnected. This will be a problem for me, but I've found some demo
code to show how to do this.
Also, here is some more information about my specific application that
may help folks to make a recommendation:
Currently using TServerSocket with ServerType := stNonBlocking
Multiple Clients connect simultaneously. In OnGetSocket, I create a
custom socket object (derived from TServerClientWinSocket) to handle
the individual connection. I don't do anything fancy with threads
here and do not expect that my code is threadsafe:
procedure TMainFrm.ServerSockGetSocket(Sender: TObject; Socket:
Integer;
var ClientSocket: TServerClientWinSocket);
begin
ClientSocket := tPalmSock.Create(Socket, TServerWinSocket(Sender),
Database, LogDB, ETDb);
end;
All communication is controlled from the client, synchronously. So
the server listens, receives a request for a connection, then reads,
processes and responds. All writing back to the client is handled in
the ServerSocket.OnRead event like so:
procedure TMainFrm.ServerSockClientRead(Sender: TObject;
Socket: TCustomWinSocket);
begin
with Socket as tPalmSock do begin
...
//read data here. When complete message received
if size = CybMsg.ContentLength then begin
try
dbClient.ProcessRequest(CybMsg);
...
repeat
bytesRead := SendBuf(CybMsg.PRespBody^,
CybMsg.ContentLength);
until bytesRead > -1;
...
Would this work in Indy? Can I do something in OnGetSocket to handle
multiple threads? Do I even need to do so?
Kimberly