Bo Berglund wrote:

thank you very much for your excellent descriptions and tips!

I did not know of CheckSynchronize before but I immediately threw in a
number of such calls in the existing code that throws the SIGSEGV
exception and Lo-and-behold! I am now getting the event output I was
expecting and no SIGSEGV exception! :)

I'm pretty sure it was mentioned a couple of days ago, since I had to ask what it was called (despite using it myself).

The sending part is a bit of a mystery to me as well because the
socket is owned by the reading thread and I don't currently know the
best way to actually tell it to transmit some data.
I got stuck by the non-appearance of the event execution before...

Threads don't own things, things are owned by processes. I'm not entirely sure about this, but I think that you could probably have one thread reading and another writing.

HOWEVER...

Finally
My communications object does not use Synchronize() for the events.
Should I add this back now that CheckSynchronize seems to have cured a
few "shortcomings"?

A lot will depend on whether you decide to use an off-the-shelf library or component suite, which would probably be appropriate if you're implementing a standard protocol. My understanding is that CheckSynchronize() does a significant amount of what the LCL main loop would do, which accounts for much of the difference between program types. Alternatively look at the lnet code that comes with FPC, I'm using the Telnet client from that to talk to things like simulated IBM mainframes.

As a general point, if you're implementing a protocol from scratch you might find it appropriate to use UDP rather than TCP. Since UDP is unreliable you'd obviously need to implement your own sequence numbers etc. to detect missed messages, but it has the advantage that messages won't need reassembly if they get fragmented due to e.g. a router having a smaller-than-expected MTU.

--
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]

--
_______________________________________________
Lazarus mailing list
[email protected]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply via email to