[fpc-pascal] fcl-net and fpasync
xrfang at gmail.com
Mon May 18 16:48:29 CEST 2015
I try to write a tcp client program, and found this page:
which is the only resource I found using fcl-net.
But there is a big problem: it did not tell how to receive message back
from the server.
I tried to write something like:
while true do begin
WriteLn('Server Reply: ' + Stream.ReadAnsiString);
//Active := false;
And at the server side,
Msg := FClientStream.ReadAnsiString;
WriteLn(AddrToString(FClientStream.PeerAddress) + ': ' + Msg);
FClientStream.WriteAnsiString('World!'); //added by me
It simply generated a runtime error: EReadError : Stream read error
As a matter of fact, I also tried to create a thread like this:
procedure TMyTCPClient.ConnStateChanged(Sender: TClientConnectionSocket;
OldState, NewState: TConnectionState);
if NewState = connConnected then begin
constructor TMyTCPClient.TMsgReceiver.Create(AStream: TSocketStream);
FStream := AStream;
FreeOnTerminate := True;
while True do begin
WriteLn('Now try to receive something...');
s := FStream.ReadAnsiString;
WriteLn('Received: ', s);
But it did not receive anything!
How can I enable **bi-directional**, asynchronous (event driven)
communication using fcl-net, also, is there any document on fpasync??
Thanks a lot!
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the fpc-pascal