title: Using ReadBytes in Indy/Lazarus
body: <p>I'm using Indy with Lazarus to write a socket application. Here is my code below.
  The socket connects properly, but when sending packets to the server, it doesn't receive anything. I must be missing something. Thanks!</p>
  
  <pre><code>procedure TSocket.IdTCPServer1Execute(AContext: TIdContext);
  var
    Socket_Receive_Buffer: TIdBytes;
    Socket_Input_Length: integer;
  
  begin
    with AContext.Connection do
    begin
      IOHandler.ReadBytes(Socket_Receive_Buffer, 1024, False);
      ShowMessage('Getting bytes');
      Socket_Input_Length := Length(Socket_Receive_Buffer);
      if Socket_Input_Length &gt; 0 then
      begin
        Writeln('received something: nb bytes = '+IntToStr(Socket_Input_Length));
      end;
    end;
  end;
  
  function TSocket.Open: boolean;
  
  begin
    if Settings.SocketModeRadioGroup.ItemIndex = 0 then
    begin
      IdTcpServer1 := TIdTCPServer.Create(nil);
      IdTCPServer1.OnExecute := @IdTCPServer1Execute;
      IdTCPServer1.OnConnect := @IdTCPServer1Connect;
      IdTCPServer1.OnDisconnect := @IdTCPServer1Disconnect;
      IdTcpServer1.DefaultPort := StrToInt(Settings.SocketPortEdit.Text);
      IdTcpServer1.MaxConnections := 1;
      IdTCPServer1.Bindings.Add.IPVersion := Id_IPv4;
      IdTcpServer1.Active := True;
      Writeln('Server started. Listening for messages');
    end
    else
    begin
      ShowMessage('Client');
  
      IdTcpClient1 := TIdTCPClient.Create(nil);
      //IdTcpClient1.DefaultPort := StrToInt(Settings.SocketPortEdit.SelText);
    end;
  end;
  </code></pre>