title: Indy SSL to plain socket pump
body: <p>I have to provide an SSL front for a plain TCP server, so I'm making a "pump" application that will provide an SSL connection to the outside while the original server can stay plain.</p>
  
  <p>I'm trying to use the Indy components to support my SSL needs, but I can't seem to get any data from the SSL port. I assigned the TIdTCPServer.OnExecute to the following event handler:</p>
  
  <pre><code>procedure TForm1.IdTCPServer1Execute(AContext: TIdContext);
  var
   c:TIdTCPClient;
   cs,ss:TIdIOHandler;
   b:TBytes;
  begin
   c:=TIdTCPClient.Create(Self);
   try
     c.Host:='127.0.0.1';
     c.Port:=60675;
     c.ConnectTimeout:=500;
     c.Connect;
     ss:=c.IOHandler;
     cs:=AContext.Connection.IOHandler;
     while (cs.Connected) and (ss.Connected) do
      begin
       if cs.CheckForDataOnSource(1) then
        begin
         try
          cs.ReadBytes(b,1,False);
         except on e:Exception do
          Memo1.Lines.Add(e.Message); //BAD out of Thread context
         end;
         if Length(b)&gt;0 then
          ss.Write(b);
        end;
       if ss.CheckForDataOnSource(1) then
        begin
         ss.ReadBytes(b,1,False);
         if Length(b)&gt;0 then
          cs.Write(b);
        end;
      end;
   finally
     c.Free;
   end;
  end;
  </code></pre>
  
  <p>The TCP server has an SSL handler attached. I did the same on a plain HTTP server and it worked fine, so I'm assuming my SSL setup is not the issue.</p>
  
  <p>cs=Client Side (the server socket) and ss=Server side (the client for the TCP server I'm trying to add SSL to).</p>
  
  <p>Now, I know it needs cleanup and doing 1ms waits isn't pretty, but before I can attack that issue, I'd like to receive some data.</p>
  
  <p>Neither of my ReadBytes get called. When I used <code>cs.Readable()</code>, I get <code>true</code> just once, but I still couldn't read.</p>
  
  <p>What can I do to make a pump? Why am I not getting data?</p>