title: Python3 socket sending ASCII text and binary (4byte) flag in one message
body: <p>Its my first question. I was lookoing through forum but cannot find fiiting aswer.
  I need to send in one message a ASCII text followed by 4 bytes (no less) composition of binary flags and than followed ASCII text</p>
  
  <p>The format of bit flags is defined as follows:</p>
  
  <p><em>Length 4 bytes b. The presence of an optional element or group of optional elements is indicated by a set bit (= 1), the absence by a non-set bit (= 0). Bits not required are 0.
  A value of 0b00000000 00000000 00000000 00000011 means that only the Fields in the Optional Elements section are sent, where the “Top. Lab” column is 1 or 2.
  For 0b00000000 00000000 00000000 01111111 all the Optional elements fields are sent where the “Top. Lab” column is one of the numbers 1 to 7.
  For 0b00000000 00000000 00000000 10000000 only the Fields in the Optional elements section are sent where the “Top. Lab” column is 8.</em></p>
  
  <p>lets say I want to send flags for field 1 and 4 so I prepared code:</p>
  
  <pre><code>ba=bytearray(4) #for bits array of flags
  ba[0]=17         #set bits 1 and 4
  message='string1'.encode('ascii') + ba + 'string2'.encode('ascii') #message to send
  socket.send(message)
  </code></pre>
  
  <ul>
  <li>Is there  better way to:</li>
  <li><ol>
  <li>build up 4 bytes bites value ?</li>
  </ol></li>
  <li><ol start="2">
  <li>send it together with ascii text in socket message?  </li>
  </ol></li>
  </ul>
  
  <p>I was trying before to send bytes directly but this gives error of concatenating or if is byte string b'0000.....0' it send it as length of 32 bytes instead of 4 bytes.  </p>
  
  <p><strong>Update:</strong>
  The 'string1' has defined length 22bytes (its header of message) and include information about and include type of message, sender id, length of 'string2'. This part is working as expected, only sending bit flags is problem for me. Up till now I was just sending 4 bytes of ascii encoded string 0000 which make me possible to receive message on other side correctly. This of course not mean 0b00000000 00000000 00000000 00000000 so other side interpret message content wrong way.</p>