 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
mike Guest
|
Posted: Wed Mar 16, 2005 11:14 am Post subject: Please help me Gambit |
|
|
Can you please give me some advice Gambit? I hate to be a pain, but I
posted 2 questions, which have been ignored. I don't expect answers
the same week or any at all, but questions posted ater mine have
already been answered. Including some very trivial questions which can
easily be found in the newsgroups answered before. (including
accessing the main VCL thread from within the non-threadsafe onexecute
method and someone who forgot to use a unit resulting in a compiler
error)
Am I doing something wrong? I searched the newsgroups at length, but
could not find clear non-conflicting answers to the following 2
questions
1) I use TIdTCPServer to receive a record, onexecute event is
something
like:
AThread.Connection.ReadBuffer(MyRecord,SizeOf(MyRecord))
this all works fine, but the problem is I can't stop the server
without an Exception (most of the time)
I try to stop it by setting IdTCPServer.Active := FALSE
Which gives a read timeout Exception (sometimes a disconnected
exception). This seems logical because the readbuffer functions has to
end because the connections are terminated. But how do I prevent the
Exception? Placing the readbuffer between try..except seems to solve
it. But is this the way to go?
I read some conflicting advises in the newsgroup and the sourcecode of
indy, one stating you should catch the exeption in the onexecute,
the other saying that Indy should handle all exceptions.
Is there perhaps something else I have to do when I want to close the
server? Are the spawned threads in the onexceute ended automatically?
2) I'm using Indy components to send records via UDP, but I think it
applies to all UDP solutions.
I understand that TCP is the safe protocol, which ensures the packets
are eventually all received in the right order. UDP will be faster
because of the lack of those checks, but can result in dataloss.
For my application it isn't a big deal if a record gets lost *in
whole* but I would like to know if I've received only half a record,
is this possible? Or are the sendbuffer commands always received in
whole or not at all? What if my record is larger than the size of a
packet? Can the record end up broken in two different packets which
trigger two seperate calls to the OnUDPRead on the server side?
From what I understand with TCP it is possible to receive a record in
fragmented parts which the Indy component neatly glues together again
when using connection.readbuffer(myrecord,sizeof(myrecord)). But how
am I ensured that with an UDP connection I only receive whole records?
Client side:
SendBuffer(IPAddress,Port,MyRecord,SizeOf(MyRecord));
Server side:
AData.ReadBuffer(MyRecord,SizeOf(MyRecord));
Would a check on the AData.Size be enough to catch incomplete records?
Thanks.
|
|
| Back to top |
|
 |
Adrien Reboisson Guest
|
Posted: Fri Mar 18, 2005 11:55 am Post subject: Re: Please help me Gambit |
|
|
| Quote: | Placing the readbuffer between try..except seems to solve
it. But is this the way to go?
|
Yes.
A.R.
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|