title: How to implement a custom binary protocol using these rules?
body: <p>I am trying to send binary data to a server that gives me back a response on doing so. The rules seems understandable to someone who is familiar with python but I am new to python and socket programming using struct. So the documentation states this:</p>
  
  <p>There is an 8 byte header that has a 32 bit integer for the request tag and a 32 bit integer for the command. The type is uint32. The buffersize depends on the type of command. </p>
  
  <p>Some commands take arguments and they are sent in tandem with the command message header directly after the header with no padding. The size of the arguments buffer is dictated by the command type. </p>
  
  <p>So I connected to the server and now I tried to package to values and send it like that but I dont know if I am doing it right.</p>
  
  <pre class="lang-py prettyprint-override"><code>import socket
  import struct
  
  # Create a TCP/IP socket
  
  from protlib import hexdump
  
  sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  server_address = ('localhost', 4200)
  sock.connect(server_address)
  
  values = (23, 42)
  packer = struct.Struct('i i ')
  packed_data = packer.pack(*values)
  
  # Send data
  sock.sendall(packed_data)
  
  while True:
      raw_data = sock.recv(1024)
      unpacked_data = struct.unpack('&gt;i i', raw_data)
      print(unpacked_data)
      sock.close()
  </code></pre>
  
  <p>If someone can just point me in the right direction and provide some guidance I will read more on it.</p>