There seems to be a couple of things wrong.
You should be using TTCPBlockSocket instead of TSocket.
You don't instantiate listener socket object.


      From: "synalist-public-requ...@lists.sourceforge.net" 
<synalist-public-requ...@lists.sourceforge.net>
 To: synalist-public@lists.sourceforge.net 
 Sent: Friday, January 26, 2018 7:06 AM
 Subject: synalist-public Digest, Vol 121, Issue 4
   
Send synalist-public mailing list submissions to
    synalist-public@lists.sourceforge.net

To subscribe or unsubscribe via the World Wide Web, visit
    https://lists.sourceforge.net/lists/listinfo/synalist-public
or, via email, send a message with subject or body 'help' to
    synalist-public-requ...@lists.sourceforge.net

You can reach the person managing the list at
    synalist-public-ow...@lists.sourceforge.net

When replying, please edit your Subject line so it is more specific
than "Re: Contents of synalist-public digest..."


Today's Topics:

  1. CanRead always False (P??ma)


----------------------------------------------------------------------

Message: 1
Date: Fri, 26 Jan 2018 11:30:35 +0100
From: P??ma <pr...@email.cz>
To: synalist-public@lists.sourceforge.net
Subject: [Synalist] CanRead always False
Message-ID: <a783cc11-8b51-93e2-5aae-fd0bde839...@email.cz>
Content-Type: text/plain; charset=utf-8; format=flowed

Hi,

When creating program to port forwarding over SSH, I found that the 
CanRead function of TCPBlockSocket return always false. This was already 
discussed on this forum in 2013 but what was the solution is not clear 
to me. At that time Synapse version 3.9 was used.

I use FPC (CodeTyphon) with Synapse 4.0. I have tried simple echo server 
demo from Synapse and I have the same issue that it not work. In 
attachment is the source code. What I'm doing wrong?

procedure TTCPEchoDaemon.Execute;
var
 ? ClientSock:TSocket;
begin
 ? with sock do
 ??? begin
 ????? CreateSocket;
 ????? setLinger(true,10000);
 ????? bind('0.0.0.0','8008');
 ????? listen;
 ????? repeat
 ??????? if terminated then break;
 ??????? if canread(1000) then {this is all the time false in my case}
 ????????? begin
 ??????????? Synchronize(@InfoCanRead);
 ??????????? ClientSock:=accept;
 ??????????? if lastError=0 then TTCPEchoThrd.create(ClientSock);
 ????????? end else Synchronize(@InfoCanNotRead);
 ????? until false;
 ??? end;
end;

Thanks for help.

With best regards

Premek




------------------------------

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot

------------------------------

Subject: Digest Footer

_______________________________________________
synalist-public mailing list
synalist-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/synalist-public


------------------------------

End of synalist-public Digest, Vol 121, Issue 4
***********************************************


   
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
synalist-public mailing list
synalist-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/synalist-public

Reply via email to