title: ServerSocket don't receiving SendText in my Server application
body: <p>I'm wanting send a file to client application (remote pc) using sockets, but ClientSocket don't receives SendText messages when I send for example as following:</p>
  
  <pre><code>ClientSocket3.Socket.SendText('&lt;|sobe|&gt;');
  </code></pre>
  
  <p>for ClientSocket3Read.</p>
  
  <p>CLIENT SIDE =></p>
  
  <pre><code>var
    tamanho: Integer;
    nome: string;
    recebendo: boolean;
    Stream: TMemoryStream;
  
  //==================================================
  
  procedure TForm1.ClientSocket2Error(Sender: TObject; Socket: TCustomWinSocket; ErrorEvent: TErrorEvent; var ErrorCode: Integer);
  begin
    ErrorCode := 0;
  end;
  
  procedure TForm1.ClientSocket2Read(Sender: TObject; Socket: TCustomWinSocket);
  var
    dados: String;
  begin
    dados := Socket.ReceiveText;
  
    if Copy(dados,1,6)='&lt;|up|&gt;' then
    Begin
      Delete(dados, 1, 6) ; // Getting only complete path with file name as example C:\file.txt from OpenDialog1 component in my Server application.
      Edit1.Text:= dados; // Receives as for example 'C:\file.txt' :D
      nome:= dados;      // // Receives as for example 'C:\file.txt' :D
      button1.Click;      // Calling button click for SendText('&lt;|sobe|'); for ClientSocket3
      exit;
    end;
  end;
  
  procedure TForm1.Button1Click(Sender: TObject);
  begin
    ClientSocket3.Socket.SendText('&lt;|sobe|&gt;');
  end;
  
  procedure TForm1.ClientSocket3Read(Sender: TObject; Socket: TCustomWinSocket);
  var
    s: string;
  begin
    s := Socket.ReceiveText;
  
    // Testing with warning message, but don't receives '&lt;|sobe|' text in: s := Socket.ReceiveText; and don't execute this line. 
  
    // Then here begins my trouble :(
  
    Application.MessageBox(pchar(s), 'Aviso', 64);
  
    //================================================================================
  
    if Recebendo = False then begin
      if Pos(#0, s)&gt;0 then begin
        Tamanho := StrToInt(Copy(s, 1, Pos(#0, s)-1));
        Delete(s, 1, Pos(#0, s));
        Stream := TMemoryStream.Create;
        Pb1.Max := tamanho; // PB1 &lt;= ProgressBar1
        Recebendo := true;
      end;
    end;
    try
      Stream.Write(s[1], Length(s));
      PB1.Position := Stream.Size;
  
      if Stream.Size &gt;= Tamanho then begin
        Stream.Position := 0;
  
        if nome = edit1.Text then begin
          Stream.SaveToFile(nome);
          Application.MessageBox('Salvo com sucesso!', 'Aviso', 64);
        end;
        Recebendo := false;
        Stream.Free;
      end;
    except
      Stream.Free;
      Recebendo := false;
    end;
  end;
  
  procedure TForm1.ClientSocket3Error(Sender: TObject; Socket: TCustomWinSocket; ErrorEvent: TErrorEvent; var ErrorCode: Integer);
  begin
    ErrorCode := 0;
  end;
  </code></pre>
  
  <p>In my Server application I send a file as:</p>
  
  <p>SERVER SIDE =></p>
  
  <pre><code>type
    TServ_Sock3 = class(TThread)
      private
        procedure Execute; override;
      public
        Socket: TCustomWinSocket;
  end;
  
      procedure TForm1.EnviarArquivo1Click(Sender: TObject);
      var
        caminho: String;
      begin
        If not Assigned(LV.Selected) then exit;
        if LV.Selected.Checked = false then exit;
  
        if OpenDialog1.Execute then begin
          caminho := opendialog1.FileName;  // 'C:\file.txt'
  
          ServerSocket1.Socket.Connections[Form1.LV.ItemIndex].SendText('&lt;|up|&gt;'+caminho);
  
          // PS: LV, is a ListView component that show me all connected computers in my network.
  
        end;
      end;
  
  procedure TServ_Sock3.Execute;
  var
    s: String;
    Stream: TMemoryStream;
  begin
    inherited;
  
    while not Terminated and Socket.Connected do begin
      if Socket.ReceiveLength&gt;0 then begin
        s := Socket.ReceiveText;
  
        if Pos('&lt;|sobe|&gt;', s)&gt;0 then begin
  
            Stream := TMemoryStream.Create;
  
             Stream.LoadFromFile(caminho);
  
            Stream.Position := 0;
            Socket.SendText(IntToStr(Stream.Size)+#0);
            Sleep(1000);
            Socket.SendStream(Stream);
          end;
        end;
  
      end;
      Sleep(10);
  end;
  
  procedure TForm1.ServerSocket2ClientError(Sender: TObject;
    Socket: TCustomWinSocket; ErrorEvent: TErrorEvent;
    var ErrorCode: Integer);
  begin
  ErrorCode:=0
  end;
  
  procedure TForm1.ServerSocket2Accept(Sender: TObject;
    Socket: TCustomWinSocket);
  var
    Conex: TServ_Sock3;
  begin
    Conex := TServ_Sock3.Create(true);
    Conex.Socket := Socket;
    Conex.FreeOnTerminate := True;
    Conex.Resume;
  
  end;
  </code></pre>
  
  <p>Can someone help me, please?</p>