title: Python Socket:Converting bytes object
body: <p>I received data via TCP socket, it should be <code>"12345678901"</code> as value. I tried also to convert it by <code>int.from_bytes</code> in <code>byteorder ='big'</code> and <code>'littel'</code>
  ,<code>struct.unpack</code>...</p>
  
  <p>However it didn't work well.</p>
  
  <p>Actual value I got is <code>b'\xd2\x04.\x16\xc5"'( &lt;&lt; data == conn.recv(2048))</code></p>
  
  <p>Which kind of way should I use for converting it to integer?</p>
  
  <p>EDIT: on Server side(really typical)</p>
  
  <pre><code>TCP_IP = '192.168.3.50'
  TCP_PORT = 8000
  BUFFER_SIZE = 2048  
  
  s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  s.bind((TCP_IP, TCP_PORT))
  s.listen(1)
  
  conn, addr = s.accept()
  print('Connection address:', addr)
  
  data_dummy = 0
  
  while 1:
  
  data = conn.recv(BUFFER_SIZE)
  if not data: break
  if data_dummy != data or data_dummy == 0:
      print("received data:", data)
      print("converted(big)", int.from_bytes(data, byteorder='big'))
      print("converted(little)", int.from_bytes(data, byteorder='little'))
  </code></pre>
  
  <p>on Client side(it is came from PLC)</p>
  
  <p>I'll put command line.</p>
  
  <pre><code>NEXT&gt;&gt; 8
  received data: b'\xd2\x04\x00\x00\x00\x00'
  converted(big) 230914621702144
  converted(little) 1234
  </code></pre>
  
  <p>It works, if is only 1234.</p>
  
  <pre><code>NEXT&gt;&gt; 9
  received data: b'\xd2\x04\x01\x00\x00\x00'
  converted(big) 230914638479360
  converted(little) 66770
  </code></pre>
  
  <p>It doesn't work, in this case 12340001.</p>
  
  <pre><code>NEXT&gt;&gt; 11
  received data: b'\xd2\x044\x12\x00\x00'
  converted(big) 230915495297024
  converted(little) 305398994
  </code></pre>
  
  <p>it doesn't work and structure itself is strange.</p>