Newsgroups : Borland : borland.public.delphi.internet.winsock : 2006 Dec : Re: TIdTcpClient / Server and pointer (indy 10)
| Subject: | Re: TIdTcpClient / Server and pointer (indy 10) |
| Posted by: | "Remy Lebeau (TeamB)" (no.spam@no.spam.com) |
| Date: | Wed, 27 Dec 2006 20:25:36 |
"Dejan Petrovic" <dejanbng@removeThis.ztbclan.com> wrote in message
news:45933001@newsgroups.borland.com...
> FSendTcp.IOHandler.Write(ms);
That is wrong. The AWriteByteCount parameter is set to False by default,
but your reading code is expecting it to be set to True instead. As such,
ReadStream() will not be able to receive the data properly, which will
usually cause some kind of error (not necessarily a socket error) in most
cases. The above line needs to look like this instead:
FSendTcp.IOHandler.Write(ms, 0, True);
> Actually, I want to be sure that stream is complete received, that
> is why I want to send small msg from client after stream is received.
That is not needed. TCP guarantees delivery and integrity. If the
unforseen happens, an error will occur on the socket.
> Also, your sugestion is preaty important, server shall receive average
> 200-300 and up to 1000-2000 small messages in time, so, I shall
> not allow client to maintain this connection open.
Why not? That is going to degrade the server's performance, not improve it.
The longer a client is allowed to keep a connection alive, the more messages
it can exchange. It is very inefficient to tear down and recreate resources
everytime a client needs to (re)connect to a server. Try to re-use
resources as much as you can.
> Do you can recomend me complete TIdTcpClient properties
> assignments and TIdTcpServer properties assigment and onExecute
> code ?
I have already given you what you need.
> Also, planing to ignore IP address whose sent undefined messages (eg.
> someone trying to made they own client in order to experiment or trying to
> hack ...). For a moment planing to made that in OnConnect and just drop
> connection, that is ok ?
It is fine to disconnect a client in the OnConnect event, yes. But that
will not prevent denial-of-service attacks and such, though.
Gambit