ReadLn()
strips off the terminator from its Result. Is your ProcessTelegram()
accounting for that? If it needs the terminator, you will have to add it back in manually, eg:
ProcessTelegram(IncomingPacket + #03)
Is ResponsePacket
being formatted correctly for what the client is expecting? If the client is not expecting a terminating CRLF, then using Write()
instead of WriteLn()
is the correct thing to do.
If you use WriteBuffer()
, you must dereference a String in order to pass the correct data address to WriteBuffer()
, eg:
WriteBuffer(ResponsePacket[1], Length(ResponsePacket), True)
Or:
WriteBuffer(PChar(ResponsePacket)^, Length(ResponsePacket), True)
If the client is still not receiving the response correctly, then either you are not sending anything at all, or you are not sending the terminator that the client is expecting. Use a packet sniffer, such as Wireshark, to see what the client is actually receiving, if anything.