Recent

Author Topic: Synapse vsVisualTCP and remote host  (Read 1098 times)

krolikbest

  • Sr. Member
  • ****
  • Posts: 276
Synapse vsVisualTCP and remote host
« on: October 06, 2020, 08:15:38 pm »
Hi,
 on the main form I put vsVisualTCP component in order to receive datas from remote host. If host is ON and is sending something then there is no problem to receive it in vsVisualTCP.OnData event. If host is OFF i get nothing of course but would be nice to know that host is off. Should I do different thread checking host status (on,off) or there is already something ready to use for this purpouse?

Regards,

krolikbest

  • Sr. Member
  • ****
  • Posts: 276
Re: Synapse vsVisualTCP and remote host
« Reply #1 on: October 08, 2020, 12:34:40 pm »
Solved.It was simply. I used TTCPBlockSocket instead of visual component within thread and checked canRead(timeout)..

BTW. I had problems to work with RegisterFileLocation (Windows) in order to use external file with css styles so did a small workaround:
- in main form onCreate event:
Code: Pascal  [Select][+][-]
  1.   // cssCount in public property of main form
  2.   cssFile := TStringList.Create;
  3.   cssFile.LoadFromFile(css_file_path);
  4.   Setlength(cssLine,cssFile.Count);
  5.   for i:=0 to cssFile.Count-1 do
  6.     cssLine[i]:=cssFile.Strings[i];
  7.   cssCount:=i+1;
  8.   cssFile.Free;
  9.  

 then in thread of my httpserver in TTestHTTPServer.HandleRequest I put something similar
Code: Pascal  [Select][+][-]
  1. ...
  2.   with AResponse.Contents do
  3.       begin
  4.          Add(' <!doctype html>');
  5.          Add(' <html>');
  6.          Add(' <head>');
  7.          Add(' <style>');
  8.          for i:=0 to form1.cssCount-1 do
  9.              Add(form1.cssLine[i]);
  10.          end;
  11.          Add(' </style>');
  12.          Add(' </head>');
  13.          Add(' <body>');              
  14. ...
  15.  

Thus that is all to use external file with css styles.

Regards,

 

TinyPortal © 2005-2018