Nice odd tcpip socket question.



I'm trying to work with client sockets, done this loads of time
before, and happily use the Indy 9 components in D5 Ent.

Today I hit a snag... The spec I have to conform to has fixed length
data packets, with no terminating character.

I tried to use idtcpclient.readln, but I can't give it a termination
character, and it appears not to return anything until it finds the
termination character, even after the timeout has exceeded and it's
returned control to the app.

I really need to be able to say "read x bytes, but give up waiting
after y seconds", something I though readln would do admirably. Alas
no. None of the other read methods allow a timeout to be set, and I
really need to keep this side under control as the eventual deployment
will be in a thread, and I don't want threads left laying about hung
because they have a tcpip connection, but for some reason the server
hasn't sent them the required number of bytes (i.e. the server process
has gone wrong).

Any ideas?

Dodgy.
--
MUSHROOMS ARE THE OPIATE OF THE MOOSES
.



Relevant Pages

  • Re: Nice odd tcpip socket question.
    ... >> data packets, with no terminating character. ... None of the other read methods allow a timeout to be set, ... >The readfromstack is the one that blocks, but it has default parameters that can adjust this behaviour. ... >Iow derive from tidtcpconnection, add a "myreadbuffer" with the above code, but WITH timeout parameters for readfromstack. ...
    (comp.lang.pascal.delphi.misc)
  • Re: Nice odd tcpip socket question.
    ... > data packets, with no terminating character. ... None of the other read methods allow a timeout to be set, ... procedure TIdTCPConnection.ReadBuffer(var ABuffer; const AByteCount: ... The readfromstack is the one that blocks, but it has default parameters that can adjust this behaviour. ...
    (comp.lang.pascal.delphi.misc)