Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
514 views
in Technique[技术] by (71.8m points)

android - Delphi cross platform: how to check if socket is connected or not

I know this question is asked a lot, I've done some search before i post my question here but still can not manage to find a solution for my problem.

In Delphi VCL, i can identify whether a socket is connected or not using;

if Socket.Connected = True then

But in Delphi FMX on Android, there is no such function!

My code:

Procedure TForm24.SocketConnect;
var
  FClientSocket: TSocket; 
  Buf: TBytes;
begin
  //Connect to VCL server
  FClientSocket := TSocket.Create(TSocketType.TCP);
  FClientSocket.Connect(string.Empty, '192.168.1.155'+#0, string.Empty, 4851);
  //if FClientSocket.Connected then
  while True do
  begin
    // Receive the message from the VCL server
    SetLength(Buf, 4);        
    FClientSocket.Receive(Buf, 4);
    // Some code here...
  end;
end;
question from:https://stackoverflow.com/questions/65541562/delphi-cross-platform-how-to-check-if-socket-is-connected-or-not

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...