title: Python: Receive data in stream, socket programming
body: <p>I had this powershell script that works perfectly,</p>
  <pre><code># The first 4 bytes are 255 which seems to be some sort of header.
  $ReceivedData = $Client.Receive([Ref]$IPEndpoint) | Select-Object -Skip 4
  $Stream = [System.IO.BinaryReader][System.IO.MemoryStream][Byte[]]$ReceivedData
  $Client.Close()
  if ($Stream) {
              # This is also a header - that will always be equal to 'I' (0x49).
              $Stream.ReadByte() | Out-Null
              [PSCustomObject]@{
                  Protocol      = [int]$Stream.ReadByte()
                  ServerName    = Get-PacketString -Stream $Stream
                  Map           = Get-PacketString -Stream $Stream
                  InstallDir    = Get-PacketString -Stream $Stream
                  GameName      = Get-PacketString -Stream $Stream
                  AppID         = [int]$Stream.ReadUInt16()
                  Players       = [int]$Stream.ReadByte()
                  MaxPlayers    = [int]$Stream.ReadByte()
                  Bots          = $Stream.ReadByte()
                  ServerType    = [ServerType]$Stream.ReadByte()
                  Environment   = [OSType]$Stream.ReadByte()
                  Visibility    = [Visibility]$Stream.ReadByte()
                  VAC           = [VAC]$Stream.ReadByte()
                  Version       = Get-PacketString -Stream $Stream
                  ExtraDataFlag = $Stream.ReadByte()
                  IPAddress     = $IPAddress
                  Port          = $Port
              }
  </code></pre>
  <p>So I wrote a small python program, that does multicasting but how to recieve the data in stream just like the ps1 script does but in python. Here's my code</p>
  <pre><code>sock.sendto(data, (MCAST_GRP, MCAST_PORT))
  msgFromServer = sock.recvfrom(1024)
  
  print(msgFromServer[0])
  </code></pre>
  <p>^But in my case I get the whole message as one, can anyone breakdown how I can achieve similar results?</p>
  <p>Thankyou</p>